]> git.lyx.org Git - features.git/commitdiff
Prevent a crash when destroying insets whose Buffers have been closed.
authorRichard Heck <rgheck@comcast.net>
Fri, 6 Jun 2008 03:11:56 +0000 (03:11 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 6 Jun 2008 03:11:56 +0000 (03:11 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25150 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/Inset.cpp
src/insets/Inset.h
src/insets/InsetBibitem.cpp
src/insets/InsetBibtex.cpp

index d83fc6629ddc029ae2a6f23ae2a2e683ce9f073b..ce754bd1fc53b92d45b78417b55a45b576f25e5b 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "buffer_funcs.h"
 #include "Buffer.h"
+#include "BufferList.h"
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "CoordCache.h"
@@ -148,6 +149,12 @@ Buffer const & Inset::buffer() const
 }
 
 
+bool Inset::isBufferValid() const
+{
+       return theBufferList().isLoaded(buffer_);
+}
+
+
 docstring Inset::name() const
 {
        return from_ascii("unknown");
index 620fc428e0e83a7c538082a26970b836b71eda64..172add48a9881ccce84c894c90a12cb1a564504c 100644 (file)
@@ -103,6 +103,9 @@ public:
        /// retrieve associated Buffer
        virtual Buffer & buffer();
        virtual Buffer const & buffer() const;
+       /// This checks whether the Buffer * actually points to an open 
+       /// Buffer. It might not if that Buffer has been closed.
+       bool isBufferValid() const;
 
        /// initialize view for this inset.
        /**
index 69599c27bbb08f5e456b930f25728c146626bd2d..f796e3c6c14284f69ef6b3a69385bc7f9440d640 100644 (file)
@@ -57,7 +57,7 @@ InsetBibitem::InsetBibitem(Buffer const & buf, InsetCommandParams const & p)
 
 InsetBibitem::~InsetBibitem()
 {
-       if (buffer_)
+       if (isBufferValid())
                buffer_->invalidateBibinfoCache();
 }
 
index 95dc99c53c40566965d704eb166f6984cef1fa56..9b0e77e7b6936654fddce7609c491bd4e296e007 100644 (file)
@@ -59,7 +59,7 @@ InsetBibtex::InsetBibtex(Buffer const & buf, InsetCommandParams const & p)
 
 InsetBibtex::~InsetBibtex()
 {
-       if (buffer_)
+       if (isBufferValid())
                buffer_->invalidateBibinfoCache();
 }