]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacro.cpp
Make sure not to use a pointer that may be bogus
[lyx.git] / src / mathed / MathMacro.cpp
index 4529cf92807800219d23035e59122ae78ab3706e..5a73742f86f555d9745772fc271c6f47de496079 100644 (file)
@@ -614,8 +614,9 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                drawMarkers2(pi, expx, expy);
        } else {
                bool drawBox = lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_INLINE_BOX;
-               bool upshape = d->macro_ && d->macro_->symbol()
-                               && d->macro_->symbol()->extra == "textmode";
+               MacroData const * macro = MacroTable::globalMacros().get(name());
+               bool upshape = macro && macro->symbol()
+                               && macro->symbol()->extra == "textmode";
                Changer dummy = pi.base.font.changeShape(upshape ? UP_SHAPE
                                                        : pi.base.font.shape());
 
@@ -929,10 +930,11 @@ bool MathMacro::folded() const
 
 void MathMacro::write(WriteStream & os) const
 {
-       bool const textmode_macro = d->macro_ && d->macro_->symbol()
-                               && d->macro_->symbol()->extra == "textmode";
-       bool const needs_mathmode = d->macro_ && (!d->macro_->symbol()
-                               || d->macro_->symbol()->extra != "textmode");
+       MacroData const * macro = MacroTable::globalMacros().get(name());
+       bool textmode_macro = macro && macro->symbol()
+                               && macro->symbol()->extra == "textmode";
+       bool needs_mathmode = macro && (!macro->symbol()
+                               || macro->symbol()->extra != "textmode");
 
        MathEnsurer ensurer(os, needs_mathmode, true, textmode_macro);