]> git.lyx.org Git - features.git/commitdiff
Add sanity check. This partially fixes a crash related to saving master
authorRichard Heck <rgheck@comcast.net>
Mon, 8 Mar 2010 13:26:08 +0000 (13:26 +0000)
committerRichard Heck <rgheck@comcast.net>
Mon, 8 Mar 2010 13:26:08 +0000 (13:26 +0000)
documents to new locations.

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

src/insets/InsetInclude.cpp

index ccd0dda6ac97c6b0251e92c265609d6011c319e9..575bfecd6cdadfffc17ae7c4911642ca1471db8b 100644 (file)
@@ -412,18 +412,18 @@ Buffer * InsetInclude::loadIfNeeded() const
        if (failedtoload_ || isVerbatim(params()) || isListings(params()))
                return 0;
 
+       FileName const included_file = includedFilename(buffer(), params());
        // Use cached Buffer if possible.
        if (child_buffer_ != 0) {
-               if (theBufferList().isLoaded(child_buffer_))
+               if (theBufferList().isLoaded(child_buffer_) 
+                               // additional sanity check: make sure the Buffer really is
+                               // associated with the file we want.
+                               && child_buffer_ == theBufferList().getBuffer(included_file))
                        return child_buffer_;
                // Buffer vanished, so invalidate cache and try to reload.
                child_buffer_ = 0;
        }
 
-       string const parent_filename = buffer().absFileName();
-       FileName const included_file = 
-               makeAbsPath(to_utf8(params()["filename"]), onlyPath(parent_filename));
-
        if (!isLyXFilename(included_file.absFilename()))
                return 0;