commit e86cdc4020bad2015e0b5bd8e7b9b683b9661035
Author: Richard Heck <[email protected]>
Date: Wed Mar 5 18:45:42 2014 -0500
Fix bug #8999 by locking math macros while they are updating.
diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp
index 2f0241b..e536af5 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 b730856..b2d7553 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_;