]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetInclude.cpp
Delete child buffer at InsetInclude destruction.
[features.git] / src / insets / InsetInclude.cpp
index d2bc2be0f98215a07fedb1f686673c2e4287205d..658d09a747e8cd845764dd990b0daffedca0a6f9 100644 (file)
@@ -167,6 +167,33 @@ InsetInclude::InsetInclude(InsetInclude const & other)
 }
 
 
+InsetInclude::~InsetInclude()
+{
+       if (isVerbatim(params()) || isListings(params()))
+               return;
+
+
+       string const parent_filename = buffer().absFileName();
+       FileName const included_file = makeAbsPath(to_utf8(params()["filename"]),
+                          onlyPath(parent_filename));
+
+       if (!isLyXFilename(included_file.absFilename()))
+               return;
+
+       Buffer * child = theBufferList().getBuffer(included_file.absFilename());
+       // File not opened, nothing to close.
+       if (!child)
+               return;
+
+       // Child document has a different parent, don't close it.
+       if (child->parent() != &buffer())
+               return;
+
+       //close the buffer.
+       theBufferList().release(child);
+}
+
+
 ParamInfo const & InsetInclude::findInfo(string const & /* cmdName */)
 {
        // FIXME
@@ -344,37 +371,6 @@ Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params)
 }
 
 
-void resetParentBuffer(Buffer const * parent, InsetCommandParams const & params,
-       bool close_it)
-{
-       if (isVerbatim(params) || isListings(params))
-               return;
-
-       string const parent_filename = parent->absFileName();
-       FileName const included_file = makeAbsPath(to_utf8(params["filename"]),
-                          onlyPath(parent_filename));
-
-       if (!isLyXFilename(included_file.absFilename()))
-               return;
-
-       Buffer * child = theBufferList().getBuffer(included_file.absFilename());
-       // File not opened, nothing to close.
-       if (!child)
-               return;
-
-       // Child document has a different parent, don't close it.
-       if (child->parent() != parent)
-               return;
-
-       //close the buffer.
-       child->setParent(0);
-       if (close_it)
-               theBufferList().release(child);
-       else
-               updateLabels(*child);
-}
-
-
 int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
 {
        string incfile = to_utf8(params()["filename"]);