From 6ed292122d9c5a2cf4a3a50e1e2e767882b81e91 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Fri, 11 Oct 2013 23:36:56 +0200 Subject: [PATCH] Make the export of macros thread-safer When we export the file to latex, we use the redefinition_ variable to check whether we should output newcommand or renewcommand. This variable was set by the MathMacroTemplate::metrics() function, and this caused problem when the export is running in a different thread as the GUI. In general, the metrics() functions should not change the Buffer; we have updateBuffer/updateMacros for that purpose. --- src/mathed/MathMacroTemplate.cpp | 8 ++------ src/mathed/MathMacroTemplate.h | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp index e82de015bf..62c681be82 100644 --- a/src/mathed/MathMacroTemplate.cpp +++ b/src/mathed/MathMacroTemplate.cpp @@ -465,7 +465,7 @@ docstring MathMacroTemplate::name() const } -void MathMacroTemplate::updateToContext(MacroContext const & mc) const +void MathMacroTemplate::updateToContext(MacroContext const & mc) { redefinition_ = mc.get(name()) != 0; } @@ -551,13 +551,9 @@ void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const // valid macro? MacroData const * macro = 0; - if (validName()) { + if (validName()) macro = mi.macrocontext.get(name()); - // updateToContext() - avoids another lookup - redefinition_ = macro != 0; - } - // update look? int argsInDef = maxArgumentInDefinition(); if (lookOutdated_ || argsInDef != argsInLook_) { diff --git a/src/mathed/MathMacroTemplate.h b/src/mathed/MathMacroTemplate.h index 61f82e9d94..0bb3d4db0b 100644 --- a/src/mathed/MathMacroTemplate.h +++ b/src/mathed/MathMacroTemplate.h @@ -87,7 +87,7 @@ public: virtual void validate(LaTeXFeatures &) const; /// decide whether its a redefinition - void updateToContext(MacroContext const & mc) const; + void updateToContext(MacroContext const & mc); /// void draw(PainterInfo & pi, int x, int y) const; @@ -164,7 +164,7 @@ private: /// (re)newcommand or def mutable MacroType type_; /// defined before already? - mutable bool redefinition_; + bool redefinition_; /// void createLook(int args) const; /// -- 2.39.2