mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-18 21:45:24 +00:00
Avoid using a dangling pointer
This can happen when a macro is copied and then the document where it is defined is closed. In this case, the macro survives in the cut stack but the the buffer pointer is dangling. This commit is an amendment to 2a9f0733 so no status line is needed.
This commit is contained in:
parent
1b596e929f
commit
180ecbd79a
@ -22,6 +22,7 @@
|
||||
#include "MathSupport.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferList.h"
|
||||
#include "BufferView.h"
|
||||
#include "CoordCache.h"
|
||||
#include "Cursor.h"
|
||||
@ -180,7 +181,10 @@ void MathMacro::assign(MathMacro const & that)
|
||||
// We need to update macro_ by ourselves because in this case
|
||||
// MathData::metrics() is not called when selecting a math inset
|
||||
DocIterator const & pos = macroBackup_.pos();
|
||||
macro_ = pos.buffer() ? pos.buffer()->getMacro(name(), pos) : 0;
|
||||
Buffer const * buf = pos.buffer();
|
||||
if (buf && !theBufferList().isLoaded(buf))
|
||||
buf = 0;
|
||||
macro_ = buf ? buf->getMacro(name(), pos) : 0;
|
||||
if (!macro_)
|
||||
macro_ = ¯oBackup_;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user