Prevent a crash when destroying insets whose Buffers have been closed.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25150 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-06-06 03:11:56 +00:00
parent 03e91b088d
commit 95a5be2891
4 changed files with 12 additions and 2 deletions

View 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");

View 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.
/**

View File

@ -57,7 +57,7 @@ InsetBibitem::InsetBibitem(Buffer const & buf, InsetCommandParams const & p)
InsetBibitem::~InsetBibitem()
{
if (buffer_)
if (isBufferValid())
buffer_->invalidateBibinfoCache();
}

View File

@ -59,7 +59,7 @@ InsetBibtex::InsetBibtex(Buffer const & buf, InsetCommandParams const & p)
InsetBibtex::~InsetBibtex()
{
if (buffer_)
if (isBufferValid())
buffer_->invalidateBibinfoCache();
}