Mercurial > octave-antonio
diff src/ov-cell.cc @ 8452:d6a349c7bd39
fix {} assigment if error occurs on subsequent assignment component
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 09 Jan 2009 15:15:43 +0100 |
parents | 7b25349b32e6 |
children | fd11a08a9b31 |
line wrap: on
line diff
--- a/src/ov-cell.cc Fri Jan 09 14:38:18 2009 +0100 +++ b/src/ov-cell.cc Fri Jan 09 15:15:43 2009 +0100 @@ -187,18 +187,22 @@ { tmp = tmp.cell_value ()(0,0); - // Erase the reference to avoid copying. - assign (idx.front (), octave_value ()); - std::list<octave_value_list> next_idx (idx); next_idx.erase (next_idx.begin ()); - // This should be a no-op. - tmp.make_unique (); - if (! tmp.is_defined () || tmp.is_zero_by_zero ()) tmp = octave_value::empty_conv (type.substr (1), rhs); + else + { + // This is a bit of black magic. tmp is a shallow copy + // of an element inside this cell, and maybe more. To + // prevent make_unique from always forcing a copy, we + // temporarily delete the stored value. + assign (idx.front (), octave_value ()); + tmp.make_unique (); + assign (idx.front (), Cell (tmp)); + } if (! error_state) t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs);