Mercurial > hg > octave-lyh
changeset 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 | 6306ce1406f1 |
children | 9e1973f7709d |
files | src/ChangeLog src/ov-cell.cc |
diffstat | 2 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-01-09 Jaroslav Hajek <highegg@gmail.com> + + * ov-cell.cc (octave_cell::subsasgn): Put erased copy back after + make_unique has been called. + 2009-01-09 Kai Habel <kai.habel@gmx.de> * graphics.cc: Calculate normals for surface boundaries, use
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -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);