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 is a further amendment to 180ecbd7.
This commit is contained in:
Enrico Forestieri 2015-07-06 20:38:35 +02:00
parent a0c2393c5d
commit e473ee8b3f

View File

@ -178,15 +178,10 @@ void MathMacro::assign(MathMacro const & that)
p->setOwner(this);
}
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(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_;
}
}