]> git.lyx.org Git - lyx.git/blobdiff - src/BufferList.cpp
* GuiDocument.cpp:
[lyx.git] / src / BufferList.cpp
index 1a8bd715f7c0d49828656f101f08c6b0248a837a..c83d3f20e235a94f6f27d47fdb6822c291fc781a 100644 (file)
@@ -29,7 +29,6 @@
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
-#include "support/os.h"
 #include "support/Package.h"
 
 #include "support/lassert.h"
@@ -328,9 +327,26 @@ Buffer * BufferList::getBufferFromTmp(string const & s)
 {
        BufferStorage::iterator it = bstore.begin();
        BufferStorage::iterator end = bstore.end();
-       for (; it < end; ++it)
-               if (prefixIs(s, (*it)->temppath()))
-                       return *it;
+       for (; it < end; ++it) {
+               if (prefixIs(s, (*it)->temppath())) {
+                       // check whether the filename matches the master
+                       string const master_name = changeExtension(onlyFilename(
+                                               (*it)->absFileName()), ".tex");
+                       if (suffixIs(s, master_name))
+                               return *it;
+                       // if not, try with the children
+                       vector<Buffer *> clist = (*it)->getChildren();
+                       vector<Buffer *>::const_iterator cit = clist.begin();
+                       vector<Buffer *>::const_iterator cend = clist.end();
+                       for (; cit < cend; ++cit) {
+                               string const mangled_child_name = DocFileName(
+                                       changeExtension((*cit)->absFileName(),
+                                               ".tex")).mangledFilename();
+                               if (suffixIs(s, mangled_child_name))
+                                       return *cit;
+                       }
+               }
+       }
        return 0;
 }