Should be safe. Note that this patch _does_ change the observable behaviour: Until now, after the deletion of a complete row a math matrix "kept" its original size on screen including the (#) at the end of the otherwise completely empty last row (everything was fine on paper or after a reload of the document). This should be fixed now. Andre' -- André Pönitz ........................................ [EMAIL PROTECTED]
Index: ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ChangeLog,v retrieving revision 1.61 diff -u -p -r1.61 ChangeLog --- ChangeLog 2001/03/09 23:55:50 1.61 +++ ChangeLog 2001/03/10 07:39:57 @@ -1,3 +1,10 @@ + +2001-03-10 André Pönitz <[EMAIL PROTECTED]> + * math_xiter.[Ch]: + math_matrixinset.C: move adjustVerticalSt to the only place where + it is used. Fix a small bug where the cached row structure and the + actual data get out of sync after the deletion of whole rows + 2001-03-09 André Pönitz <[EMAIL PROTECTED]> * math_cursor.C: use std::vector<> in MathStackXIter change selstk from a pointer to the "real thing" Index: math_matrixinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_matrixinset.C,v retrieving revision 1.15 diff -u -p -r1.15 math_matrixinset.C --- math_matrixinset.C 2001/03/08 22:19:55 1.15 +++ math_matrixinset.C 2001/03/10 07:39:57 @@ -93,11 +93,27 @@ void MathMatrixInset::draw(Painter & pai void MathMatrixInset::Metrics() { - if (row_.empty()) { + //if (row_.empty()) { +#warning This leaks row_.data but goes away soon // lyxerr << " MIDA "; MathedXIter it(this); - row_.data_ = it.adjustVerticalSt(); - } + it.GoBegin(); + if (!it.crow_) { + it.crow_.st_ = new MathedRowSt(it.ncols + 1); // this leaks + } + MathedRowSt * mrow = it.crow_.st_; + while (it.OK()) { + if (it.IsCR()) { + if (it.col >= it.ncols) + it.ncols = it.col + 1; + MathedRowSt * r = new MathedRowSt(it.ncols + 1); // +this leaks + it.crow_.st_->next_ = r; + it.crow_.st_ = r; + } + it.Next(); + } + row_.data_ = mrow; + //} // Clean the arrays for (MathedRowContainer::iterator it = row_.begin(); it; ++it) Index: math_xiter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_xiter.C,v retrieving revision 1.17 diff -u -p -r1.17 math_xiter.C --- math_xiter.C 2001/03/09 08:45:10 1.17 +++ math_xiter.C 2001/03/10 07:39:57 @@ -571,26 +571,6 @@ bool MathedXIter::setLabel(string const } -MathedRowSt * MathedXIter::adjustVerticalSt() -{ - GoBegin(); - if (!crow_) { - crow_.st_ = new MathedRowSt(ncols + 1); // this leaks - } - MathedRowSt * mrow = crow_.st_; - while (OK()) { - if (IsCR()) { - if (col >= ncols) - ncols = col + 1; - MathedRowSt * r = new MathedRowSt(ncols + 1); // this leaks - crow_.st_->next_ = r; - crow_.st_ = r; - } - Next(); - } - return mrow; -} - string const & MathedXIter::getLabel() const { Index: math_xiter.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_xiter.h,v retrieving revision 1.10 diff -u -p -r1.10 math_xiter.h --- math_xiter.h 2001/03/08 11:51:35 1.10 +++ math_xiter.h 2001/03/10 07:39:57 @@ -7,6 +7,7 @@ #include "math_rowst.h" class MathParInset; +class MathMatrixInset; /** A graphic iterator (updates position.) Used for @@ -76,8 +77,6 @@ public: /// Delete every object from current position to pos2 void Clean(int pos2); /// - MathedRowSt * adjustVerticalSt(); - /// virtual void ipush(); /// virtual void ipop(); @@ -86,7 +85,7 @@ public: return crow_; } -private: +protected: /// MathedRowContainer & container(); /// This function is not recursive, as MathPar::Metrics is @@ -110,6 +109,6 @@ private: /// MathedRowContainer::iterator crow_; /// - //friend class MathedCursor; + friend class MathMatrixInset; }; #endif