Hi,
The attached patch to dociterator.C should be obviously correct. You can not access a textRow if there are none. If you apply this, you will also get an assertion failure in text.C breakParagraph as I do without even this patch, because MSVC is so kind to flag a memory access error due to poisoning.
So, to avoid that assertion, I simply add a check before we ask for the textRow at that place in the code. See the patch to text.C. That fixes the crash, and break works for me now. Maybe the fix is not the best, but it is a monotoneous improvement: At least it does not crash anymore. (To reproduce the bug, start a new document, write something and press Return.)
In addition, I also attach a patch to paragraph.C to find more of these problems.
Well, I meant to include a patch to text.C, but it has been trying to make a diff for half an hour without any success. I just attach the latest version instead. You can make your own diff.
Regards, Asger
Index: src/dociterator.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dociterator.C,v retrieving revision 1.21 diff -u -r1.21 dociterator.C --- src/dociterator.C 30 Nov 2004 01:59:33 -0000 1.21 +++ src/dociterator.C 25 Jan 2005 13:34:51 -0000 @@ -146,12 +146,14 @@ Row & DocIterator::textRow() { + BOOST_ASSERT(!paragraph().rows().empty()); return paragraph().getRow(pos()); } Row const & DocIterator::textRow() const { + BOOST_ASSERT(!paragraph().rows().empty()); return paragraph().getRow(pos()); }
Index: src/paragraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v retrieving revision 1.400 diff -u -r1.400 paragraph.C --- src/paragraph.C 24 Jan 2005 17:12:18 -0000 1.400 +++ src/paragraph.C 25 Jan 2005 13:41:00 -0000 @@ -1795,6 +1795,8 @@ Row & Paragraph::getRow(pos_type pos) { + BOOST_ASSERT(!rows().empty()); + RowList::iterator rit = rows_.end(); RowList::iterator const begin = rows_.begin(); @@ -1807,6 +1809,8 @@ Row const & Paragraph::getRow(pos_type pos) const { + BOOST_ASSERT(!rows().empty()); + RowList::const_iterator rit = rows_.end(); RowList::const_iterator const begin = rows_.begin(); @@ -1819,6 +1823,8 @@ size_t Paragraph::pos2row(pos_type pos) const { + BOOST_ASSERT(!rows().empty()); + RowList::const_iterator rit = rows_.end(); RowList::const_iterator const begin = rows_.begin();
text.C.bz2
Description: Binary data