Avoid calling Buffer::getMacro inside the MathMacro copy constructor

It turns out that it is always better using the copy of the MacroData
for updating the macro_ pointer to avoid problems related to the cursor
position.
This commit is contained in:
Enrico Forestieri 2015-07-05 20:44:54 +02:00
parent 2ea3e07a23
commit 4dff1394ab

View File

@ -194,15 +194,10 @@ void MathMacro::Private::updateChildren(MathMacro * owner)
}
if (macro_ && lyxrc.preview == LyXRC::PREVIEW_ON) {
// 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();
Buffer const * buf = pos.buffer();
if (buf && !theBufferList().isLoaded(buf))
buf = 0;
macro_ = buf ? buf->getMacro(owner->name(), pos) : 0;
if (!macro_)
macro_ = &macroBackup_;
// As MathData::metrics() is not called when instant preview is
// on, we have to update macro_ by ourselves. In this case, we
// simply let it point to the last known good copy of MacroData.
macro_ = &macroBackup_;
}
}