Abdelrazak Younes wrote:
Abdelrazak Younes wrote:
Jürgen Spitzmüller wrote:
- open the German user guide
- right-click on the LOF-inset to open the outliner
- click in outliner to navigate to the second figure
- set cursor before first figure (just one line above) and hit delete to delete it
- note that the figure list is not updated
- click on the now invalid entry. Eventually LyX will crash.

Yes, I can reproduce this. It seems that a call to updateLabels() is missing somewhere.

Note that if DEPM is triggered after the deletion, updateLabels() will be called and the crash will not happen. So we need to detect when we delete a caption. But this issue will pop up again with the list of notes and the list of foot notes. Perhaps we should just call updateLabels() each time we delete any inset?

That's what I did. Please backport it to branch Juergen.

Abdel.


Author: younes
Date: Wed Feb 13 15:16:51 2008
New Revision: 22979

URL: http://www.lyx.org/trac/changeset/22979
Log:
Fix crash when deleting outlined insets while the outline panel is open.

Modified:
    lyx-devel/trunk/src/Text.cpp

Modified: lyx-devel/trunk/src/Text.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Text.cpp?rev=22979
==============================================================================
--- lyx-devel/trunk/src/Text.cpp (original)
+++ lyx-devel/trunk/src/Text.cpp Wed Feb 13 15:16:51 2008
@@ -928,11 +928,15 @@
                // this is the code for a normal delete, not pasting
                // any paragraphs
                cur.recordUndo(DELETE_UNDO);
-               if(!par.eraseChar(cur.pos(), 
cur.buffer().params().trackChanges)) {
+               bool const was_inset = cur.paragraph().isInset(cur.pos());
+               if(!par.eraseChar(cur.pos(), 
cur.buffer().params().trackChanges))
                        // the character has been logically deleted only => 
skip it
                        cur.top().forwardPos();
-               }
-               cur.checkBufferStructure();
+
+               if (was_inset)
+                       updateLabels(cur.buffer());
+               else
+                       cur.checkBufferStructure();
                needsUpdate = true;
        } else {
                if (cur.pit() == cur.lastpit())
@@ -1043,8 +1047,12 @@
                // without the dreaded mechanism. (JMarc)
                setCursorIntern(cur, cur.pit(), cur.pos() - 1,
                                false, cur.boundary());
+               bool const was_inset = cur.paragraph().isInset(cur.pos());
cur.paragraph().eraseChar(cur.pos(), cur.buffer().params().trackChanges);
-               cur.checkBufferStructure();
+               if (was_inset)
+                       updateLabels(cur.buffer());
+               else
+                       cur.checkBufferStructure();
        }

        if (cur.pos() == cur.lastpos())



Reply via email to