]> git.lyx.org Git - features.git/commitdiff
Fix bug 5699 (crash when using outliner in child document while the master is not...
authorVincent van Ravesteijn <vfr@lyx.org>
Thu, 19 Feb 2009 00:29:04 +0000 (00:29 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Thu, 19 Feb 2009 00:29:04 +0000 (00:29 +0000)
The problem was that, if the master is not opened, no respective guiDelegate exists, and the functions that update the toc do not trigger. The fix is to update the child's toc backend and toc items directly in such cases.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28551 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Buffer.h
src/Cursor.cpp

index bd33995e9cefdfd381d68bba7d923b083fb92b79..d977e2c2112e45a8dade542c17cafbcfebdd3a78 100644 (file)
@@ -2287,6 +2287,12 @@ void Buffer::resetAutosaveTimers() const
 }
 
 
+bool Buffer::hasGuiDelegate() const
+{
+       return gui_;
+}
+
+
 void Buffer::setGuiDelegate(frontend::GuiBufferDelegate * gui)
 {
        gui_ = gui;
@@ -2719,6 +2725,10 @@ void Buffer::updateLabels(bool childonly) const
                if (master != this) {
                        bufToUpdate.insert(this);
                        master->updateLabels(false);
+                       // Do this here in case the master has no gui associated with it. Then, 
+                       // the TocModel is not updated and TocModel::toc_ is invalid (bug 5699).
+                       if (!master->gui_)
+                               structureChanged();     
 
                        // was buf referenced from the master (i.e. not in bufToUpdate anymore)?
                        if (bufToUpdate.find(this) == bufToUpdate.end())
index e91f7e82732c5c894ba412d4cf741dc064561694..f4f33d46cf3a7c88f38c405bc351a646fb8fa72f 100644 (file)
@@ -442,7 +442,10 @@ public:
        ///
        void message(docstring const & msg) const;
 
+       ///
        void setGuiDelegate(frontend::GuiBufferDelegate * gui);
+       ///
+       bool Buffer::hasGuiDelegate() const;
 
        ///
        void autoSave() const;
index ce6997ed5981d87ab285a9626e72da4a2657501a..1cfd32dd88994dd0a4df5adf4e69387d800f7c08 100644 (file)
@@ -2211,6 +2211,10 @@ void Cursor::checkBufferStructure()
 {
        Buffer const * master = buffer()->masterBuffer();
        master->tocBackend().updateItem(*this);
+       if (master != buffer() && !master->hasGuiDelegate())
+               // In case the master has no gui associated with it, 
+               // the TocItem is not updated (part of bug 5699).
+               buffer()->tocBackend().updateItem(*this);
 }