Fix bug #8999 by locking math macros while they are updating.

This commit is contained in:
Richard Heck 2014-03-05 18:45:42 -05:00
parent 99059742c6
commit e86cdc4020
2 changed files with 22 additions and 0 deletions

View File

@ -312,9 +312,27 @@ void MathMacro::updateMacro(MacroContext const & mc)
}
class MathMacro::UpdateLocker
{
public:
explicit UpdateLocker(MathMacro & mm) : mac(mm)
{
mac.isUpdating_ = true;
}
~UpdateLocker() { mac.isUpdating_ = false; }
private:
MathMacro & mac;
};
void MathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc,
UpdateType utype)
{
if (isUpdating_)
return;
UpdateLocker(*this);
// known macro?
if (macro_ == 0)
return;

View File

@ -183,6 +183,10 @@ private:
std::string requires_;
/// update macro representation
bool needsUpdate_;
/// update lock to avoid loops
class UpdateLocker;
friend class UpdateLocker;
bool isUpdating_;
/// maximal number of arguments the macro is greedy for
size_t appetite_;