diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 9252083331..56f81a59f7 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,10 @@ + +2001-03-10 André Pönitz + * 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 * math_cursor.C: use std::vector<> in MathStackXIter change selstk from a pointer to the "real thing" diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index 30842ab21a..6964eaeabd 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -93,11 +93,27 @@ void MathMatrixInset::draw(Painter & pain, int x, int baseline) 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) diff --git a/src/mathed/math_xiter.C b/src/mathed/math_xiter.C index d242a58081..c29e1b6d46 100644 --- a/src/mathed/math_xiter.C +++ b/src/mathed/math_xiter.C @@ -571,26 +571,6 @@ bool MathedXIter::setLabel(string const & label) } -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 { diff --git a/src/mathed/math_xiter.h b/src/mathed/math_xiter.h index fb5201aafb..6012083339 100644 --- a/src/mathed/math_xiter.h +++ b/src/mathed/math_xiter.h @@ -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