commit 11fd6fe43d3f91494910deab045341da1966f89f
Author: Enrico Forestieri <[email protected]>
Date: Sun Jun 9 22:35:05 2019 +0200
Fix bug #11595
Avoid an endless loop when in the definition of a macro the macro
itself is used in the LyX representation part.
(cherry picked from commit 1cb2a443b5c09e3a0abc93716aceadd49eee7f56)
---
src/mathed/InsetMathMacro.cpp | 17 ++++++++++-------
status.23x | 2 ++
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index d1bb67d..1164abf 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -661,17 +661,20 @@ void InsetMathMacro::updateRepresentation(Cursor * cur,
MacroContext const & mc,
values[i].insert(0, MathAtom(proxy));
}
// expanding macro with the values
- // Only update the argument macros if anything was expanded, otherwise
- // we would get an endless loop (bug 9140). UpdateLocker does not work
- // in this case, since MacroData::expand() creates new InsetMathMacro
- // objects, so this would be a different recursion path than the one
- // protected by UpdateLocker.
- if (d->macro_->expand(values, d->expanded_)) {
+ // Only update the argument macros if anything was expanded or the LyX
+ // representation part does not contain the macro itself, otherwise we
+ // would get an endless loop (bugs 9140 and 11595). UpdateLocker does
+ // not work in this case, since MacroData::expand() creates new
+ // InsetMathMacro objects, so this would be a different recursion path
+ // than the one protected by UpdateLocker.
+ docstring const & display = d->macro_->display();
+ docstring const latexname = from_ascii("\\") + macroName();
+ if (d->macro_->expand(values, d->expanded_)
+ && !support::contains(display, latexname)) {
if (utype == OutputUpdate && !d->expanded_.empty())
d->expanded_.updateMacros(cur, mc, utype, nesting);
}
// get definition for list edit mode
- docstring const & display = d->macro_->display();
asArray(display.empty() ? d->macro_->definition() : display,
d->definition_, Parse::QUIET | Parse::MACRODEF);
}
diff --git a/status.23x b/status.23x
index 105ca85..245a1cd 100644
--- a/status.23x
+++ b/status.23x
@@ -54,6 +54,8 @@ What's new
- Deal properly with orphaned bibitems (bug 7160).
+- Fix endless loop when a macro definition references itself (bug 11595).
+
* INTERNALS