From: Enrico Forestieri Date: Wed, 14 Sep 2016 00:27:18 +0000 (+0200) Subject: Make sure not to use a pointer that may be bogus X-Git-Tag: 2.3.0alpha1~1028 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8ec91e804a038982d07fc2f88511da8579b9b523;p=features.git Make sure not to use a pointer that may be bogus It may happen that mathedWordList is not still updated at load time, so we would still be using a bogus pointer. Better fetching the necessary info from the global macro table. --- diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index cb853a3ba9..5a73742f86 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -614,9 +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 user_macro = mathedWordList().find(name()) == mathedWordList().end(); - bool upshape = user_macro ? false : 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()); @@ -930,11 +930,11 @@ bool MathMacro::folded() const void MathMacro::write(WriteStream & os) const { - bool user_macro = mathedWordList().find(name()) == mathedWordList().end(); - bool textmode_macro = user_macro ? false : d->macro_ && d->macro_->symbol() - && d->macro_->symbol()->extra == "textmode"; - bool needs_mathmode = user_macro ? bool(d->macro_) : 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);