commit 3c1969574f2a8ceeb035146d79e482289d9e80ec
Author: Enrico Forestieri <[email protected]>
Date:   Sat Feb 22 10:30:55 2014 -0500

    Fix bug #8889 by always issuing \protect in fragile environments.

diff --git a/src/mathed/InsetMathPhantom.cpp b/src/mathed/InsetMathPhantom.cpp
index bbc2234..cd4ae45 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 fe6e918..2f0241b 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();

Reply via email to