This fixes the crash, but I think it hides the real problem. I'm sending a patch in a moment that I think deals with the underlying issue.

Richard

Bo Peng wrote:
As I have analyzed in another email, the crash is caused by

1. load child doc 2 ==> child doc 2 loaded, switch to child doc 2,
setBuffer(child doc 2), which disconnect the master buffer.

2. load child doc 1 ==> child doc 1 loaded, fire structureChanged()
from its master buffer. However, the master buffer is currently
disconnected so updateToc is not called.

3. When the Toc panel is updated, its Toc is outdated, leading to MSVC
iterator validation assertion.

Attached patch fixes the crash, although I am not quite sure about
other side effects. My understanding is that this remaining signal
will not cause any harm even if it becomes broken later.

Cheers,
Bo
------------------------------------------------------------------------

Index: src/frontends/LyXView.cpp
===================================================================
--- src/frontends/LyXView.cpp   (revision 19272)
+++ src/frontends/LyXView.cpp   (working copy)
@@ -308,7 +308,21 @@
 {
        errorsConnection_.disconnect();
        bufferChangedConnection_.disconnect();
-       bufferStructureChangedConnection_.disconnect();
+       // http://bugzilla.lyx.org/show_bug.cgi?id=4096
+       //
+       // The master buffer, even when it is not the current buffer and is
+       // disconnected by setBuffer(its_child_buffer), need to accept
+       // structureChanged() signal so that updateToc() can be called properly
+       // to update Toc for this document. Otherwise, bug 4096 will crash lyx,
+       // which is caused by
+       //    load child doc 2   ==> child doc 2 loaded
+       //                           connect child doc2
+       //                           disconnect master doc
+       //    load child doc 1   ==> child doc 1 loaded
+       //                           fire structureChanged()
+       //    updateToc() is not called because master buffer is disconnected
+       //
+       // bufferStructureChangedConnection_.disconnect();
        messageConnection_.disconnect();
        busyConnection_.disconnect();
        titleConnection_.disconnect();


--
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto

Reply via email to