mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-08 10:51:03 +00:00
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:
parent
03e91b088d
commit
95a5be2891
@ -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");
|
||||
|
@ -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.
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ InsetBibitem::InsetBibitem(Buffer const & buf, InsetCommandParams const & p)
|
||||
|
||||
InsetBibitem::~InsetBibitem()
|
||||
{
|
||||
if (buffer_)
|
||||
if (isBufferValid())
|
||||
buffer_->invalidateBibinfoCache();
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ InsetBibtex::InsetBibtex(Buffer const & buf, InsetCommandParams const & p)
|
||||
|
||||
InsetBibtex::~InsetBibtex()
|
||||
{
|
||||
if (buffer_)
|
||||
if (isBufferValid())
|
||||
buffer_->invalidateBibinfoCache();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user