]> git.lyx.org Git - features.git/commitdiff
Fix bug #8999 by locking math macros while they are updating.
authorRichard Heck <rgheck@lyx.org>
Wed, 5 Mar 2014 23:45:42 +0000 (18:45 -0500)
committerRichard Heck <rgheck@lyx.org>
Wed, 5 Mar 2014 23:46:38 +0000 (18:46 -0500)
src/mathed/MathMacro.cpp
src/mathed/MathMacro.h

index 2f0241b5ac50b5bf6cc07a8252a0a1f5641e4f8c..e536af5372ea79612a75897911578d65b4348e8c 100644 (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;
index b7308562ff2df2c26b58733081e78e2a3e8522e8..b2d75534d2a04376ba42a573209c31b5de07c0e8 100644 (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_;