From: Richard Heck Date: Wed, 5 Mar 2014 23:45:42 +0000 (-0500) Subject: Fix bug #8999 by locking math macros while they are updating. X-Git-Tag: 2.1.0rc1~108 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e86cdc4020bad2015e0b5bd8e7b9b683b9661035;p=features.git Fix bug #8999 by locking math macros while they are updating. --- diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index 2f0241b5ac..e536af5372 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -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; diff --git a/src/mathed/MathMacro.h b/src/mathed/MathMacro.h index b7308562ff..b2d75534d2 100644 --- a/src/mathed/MathMacro.h +++ b/src/mathed/MathMacro.h @@ -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_;