]> git.lyx.org Git - features.git/commitdiff
Really fix the problem with not updated macros
authorEnrico Forestieri <forenr@lyx.org>
Thu, 15 Sep 2016 00:39:30 +0000 (02:39 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 15 Sep 2016 00:39:30 +0000 (02:39 +0200)
Revert to the strategy used at 8f86ee74 but not using mathedWordList
because it may be still uninitialized at load time. Instead, use the
globalMacros method for getting the same info.
There was a thinko at 8ec91e80, because globalMacros always returns
null for user defined macros.

src/BufferView.cpp
src/mathed/MathMacro.cpp

index fa95d400c7e6866cf8670499a493d79206f84b04..fad015480ec97a8f49f0c26d5dd782ca6f5872e8 100644 (file)
@@ -495,7 +495,9 @@ void BufferView::processUpdateFlags(Update::flags flags)
 
        // updateMetrics() does not update paragraph position
        // This is done at draw() time. So we need a redraw!
-       buffer_.changed(false);
+       // We pass true so that metrics are computed for the sake
+       // of having MacroData updated.
+       buffer_.changed(true);
 
        if (needsFitCursor()) {
                // The cursor is off screen so ensure it is visible.
@@ -2165,7 +2167,9 @@ void BufferView::updateHoveredInset() const
 
                // This event (moving without mouse click) is not passed further.
                // This should be changed if it is further utilized.
-               buffer_.changed(false);
+               // We pass true so that metrics are computed for the sake
+               // of having MacroData updated.
+               buffer_.changed(true);
        }
 }
 
index 5a73742f86f555d9745772fc271c6f47de496079..e1484e81b11708d4c42645e72483236db568427d 100644 (file)
@@ -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;
-               MacroData const * macro = MacroTable::globalMacros().get(name());
-               bool upshape = macro && macro->symbol()
-                               && macro->symbol()->extra == "textmode";
+               bool user_macro = !MacroTable::globalMacros().get(name());
+               bool upshape = user_macro ? false : d->macro_ && d->macro_->symbol()
+                               && d->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
 {
-       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");
+       bool user_macro = !MacroTable::globalMacros().get(name());
+       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");
 
        MathEnsurer ensurer(os, needs_mathmode, true, textmode_macro);