From: Enrico Forestieri Date: Sat, 22 Feb 2014 15:30:55 +0000 (-0500) Subject: Fix bug #8889 by always issuing \protect in fragile environments. X-Git-Tag: 2.1.0rc1~171 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=3c1969574f2a8ceeb035146d79e482289d9e80ec;p=features.git Fix bug #8889 by always issuing \protect in fragile environments. --- 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();