Abdelrazak Younes wrote:
Richard Heck wrote:
Idea for fix: Since the buffer_func.cpp version of loadLyXFile() is called from LyXView::loadLyXFile(), anyway, all the child doc stuff could be moved there. But I don't know this code terribly well. Abdel?

Very good analysis Richard! The solution is to use the LFUN instead of using loadLyXFile from buffer_funcs.cpp. This should fix the problem.

Does this patch (on top of the other) fixes the problem?

Abdel.
Index: InsetInclude.cpp
===================================================================
--- InsetInclude.cpp    (revision 18780)
+++ InsetInclude.cpp    (working copy)
@@ -26,6 +26,7 @@
 #include "gettext.h"
 #include "LaTeXFeatures.h"
 #include "LyX.h"
+#include "LyXFunc.h"
 #include "LyXRC.h"
 #include "Lexer.h"
 #include "MetricsInfo.h"
@@ -400,12 +401,10 @@
                // the readonly flag can/will be wrong, not anymore I think.
                if (!fs::exists(included_file.toFilesystemEncoding()))
                        return false;
-               buf = theBufferList().newBuffer(included_file.absFilename());
-               if (!loadLyXFile(buf, included_file)) {
-                       //close the buffer we just opened
-                       theBufferList().close(buf, false);
-                       return false;
-               }
+               dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN,
+                       included_file.absFilename()));
+               buf = theBufferList().getBuffer(included_file.absFilename());
+               return buf;
        }
        buf->setParentName(parentFilename(buffer));
        return true;

Reply via email to