fix crash discovered by Michael

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3085 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-11-27 09:44:32 +00:00
parent 235ded7751
commit 62818cea01
2 changed files with 19 additions and 23 deletions

View File

@ -952,7 +952,7 @@ void MathCursor::normalize() const
<< idx() << " " << par()->nargs() << "\n"; << idx() << " " << par()->nargs() << "\n";
dump("error 2"); dump("error 2");
} }
it->idx() = min(idx(), par()->nargs() - 1); it->idx() = min(idx(), par()->nargs() - 1);
if (pos() > size()) { if (pos() > size()) {
lyxerr << "this should not really happen - 2: " lyxerr << "this should not really happen - 2: "
@ -1058,7 +1058,7 @@ void MathCursor::idxPrev()
void MathCursor::splitCell() void MathCursor::splitCell()
{ {
if (idx() == par()->nargs() - 1) if (idx() + 1 == par()->nargs())
return; return;
MathArray ar = array(); MathArray ar = array();
ar.erase(0, pos()); ar.erase(0, pos());

View File

@ -403,7 +403,7 @@ bool MathGridInset::idxLeft(idx_type & idx, pos_type & pos) const
bool MathGridInset::idxRight(idx_type & idx, pos_type & pos) const bool MathGridInset::idxRight(idx_type & idx, pos_type & pos) const
{ {
// leave matrix if on the right hand edge // leave matrix if on the right hand edge
if (col(idx) == ncols() - 1) if (col(idx) + 1 == ncols())
return false; return false;
idx++; idx++;
pos = 0; pos = 0;
@ -490,30 +490,26 @@ void MathGridInset::idxDelete(idx_type & idx, bool & popit, bool & deleteit)
popit = false; popit = false;
deleteit = false; deleteit = false;
// delete entire sequence of ncols() empty cells if possible // nothing to do if we are in the last row of the inset
if (idx <= index(nrows() - 1, 0)) { if (row(idx) + 1 == nrows())
bool deleterow = true; return;
for (idx_type i = idx; i < idx + ncols(); ++i)
if (cell(i).size()) {
deleterow = false;
break;
}
if (deleterow) { // try to delete entire sequence of ncols() empty cells if possible
// move cells if necessary for (idx_type i = idx; i < idx + ncols(); ++i)
for (idx_type i = index(row(idx), 0); i < idx; ++i) if (cell(i).size())
cell(i).swap(cell(i + ncols()));
delRow(row(idx));
if (idx >= nargs())
idx = nargs() - 1;
return; return;
}
} // move cells if necessary
for (idx_type i = index(row(idx), 0); i < idx; ++i)
cell(i).swap(cell(i + ncols()));
delRow(row(idx));
if (idx >= nargs())
idx = nargs() - 1;
// undo effect of Ctrl-Tab (i.e. pull next cell) // undo effect of Ctrl-Tab (i.e. pull next cell)
//if (idx != nargs() - 1) //if (idx + 1 != nargs())
// cell(idx).swap(cell(idx + 1)); // cell(idx).swap(cell(idx + 1));
} }