]> git.lyx.org Git - features.git/commitdiff
If a file is saved as, reset its master if it has any, thus preventing a crash (bug...
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 19 May 2012 08:16:28 +0000 (10:16 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 19 May 2012 08:16:28 +0000 (10:16 +0200)
src/Buffer.cpp
src/Buffer.h

index ad119bdbf172a0d372756547eadab05a6cfeb8b1..54c34c20dbae0bc9d9400f4bf8f1c823674a235c 100644 (file)
@@ -4591,6 +4591,7 @@ bool Buffer::saveAs(FileName const & fn)
                // we need to check that the locations of child buffers
                // are still valid.
                checkChildBuffers();
+               checkMasterBuffer();
                return true;
        } else {
                // save failed
@@ -4639,4 +4640,25 @@ void Buffer::checkChildBuffers()
        d->position_to_children.clear();
 }
 
+
+// If a child has been saved under a different name/path, it might have been
+// orphaned. Therefore the master needs to be reset (bug 8161).
+void Buffer::checkMasterBuffer()
+{
+       Buffer const * const master = masterBuffer();
+       if (master == this)
+               return;
+
+       // necessary to re-register the child (bug 5873)
+       // FIXME: clean up updateMacros (here, only
+       // child registering is needed).
+       master->updateMacros();
+       // (re)set master as master buffer, but only
+       // if we are a real child
+       if (master->isChild(this))
+               setParent(master);
+       else
+               setParent(0);
+}
+
 } // namespace lyx
index 3c4d0f40d08b81335a813ce524227f3e3727e112..fc02c6a05d3c7985f87b94a4e44a20c6d8efcc6c 100644 (file)
@@ -691,6 +691,8 @@ public:
                WordLangTuple & word_lang, docstring_list & suggestions) const;
        ///
        void checkChildBuffers();
+       ///
+       void checkMasterBuffer();
 
        /// compute statistics between \p from and \p to
        /// \p from initial position