From 3c1969574f2a8ceeb035146d79e482289d9e80ec Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sat, 22 Feb 2014 10:30:55 -0500 Subject: [PATCH] Fix bug #8889 by always issuing \protect in fragile environments. --- src/mathed/InsetMathPhantom.cpp | 2 ++ src/mathed/MathMacro.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mathed/InsetMathPhantom.cpp b/src/mathed/InsetMathPhantom.cpp index bbc2234a18..cd4ae451cf 100644 --- a/src/mathed/InsetMathPhantom.cpp +++ b/src/mathed/InsetMathPhantom.cpp @@ -240,6 +240,8 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const void InsetMathPhantom::write(WriteStream & os) const { MathEnsurer ensurer(os); + if (os.fragile()) + os << "\\protect"; switch (kind_) { case phantom: os << "\\phantom{"; diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index fe6e9188b0..2f0241b5ac 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -707,8 +707,8 @@ void MathMacro::write(WriteStream & os) const // we should be ok to continue even if this fails. LATTEST(macro_); - // optional arguments make macros fragile - if (optionals_ > 0 && os.fragile()) + // Always protect macros in a fragile environment + if (os.fragile()) os << "\\protect"; os << "\\" << name(); -- 2.39.2