Lars, please have a look. // This is the comments that some of the warnings below refers to. // There are some issues in this file and I don't think they are // really related to the FIX_DOUBLE_SPACE patch. I'd rather think that // this is a problem that has been here almost from day one and that a // larger userbase with different access patters triggers the bad // behaviour. (segfaults.) What I think happen is: In several places // we store the paragraph in the current cursor and then moves the // cursor. This movement of the cursor will delete paragraph at the // old position if it is now empty. This will make the temporary // pointer to the old cursor paragraph invalid and dangerous to use. // And is some cases this will trigger a segfault. I have marked some // of the cases where this happens with a warning, but I am sure there // are others in this file and in text2.C. There is also a note in // Delete() that you should read. In Delete I store the paragraph->id // instead of a pointer to the paragraph. I am pretty sure this faulty // use of temporary pointers to paragraphs that might have gotten // invalidated (through a cursor movement) before they are used, are // the cause of the strange crashes we get reported often. // // It is very tiresom to change this code, especially when it is as // hard to read as it is. Help to fix all the cases where this is done // would be greately appreciated. // // Lgb [...] // Delete from cursor up to the end of the current or next word. void LyXText::deleteWordForward() { if (cursorPar()->empty()) cursorRight(bv()); else { LyXCursor tmpcursor = cursor; selection.set(true); // to avoid deletion cursorRightOneWord(); setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); selection.cursor = cursor; cursor = tmpcursor; setSelection(); cutSelection(true, false); } }
I don't think much of this comment is valid anymore. We don't have much PragraphList::iterators anymore, most notably, there is none stored in the cursor. The paragraph->id solution seems to be gone as well. What should we do? Adjust the note or remove it completely? Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)