]> git.lyx.org Git - features.git/commitdiff
Make the export of macros thread-safer
authorVincent van Ravesteijn <vfr@lyx.org>
Fri, 11 Oct 2013 21:36:56 +0000 (23:36 +0200)
committerVincent van Ravesteijn <vfr@lyx.org>
Sat, 12 Oct 2013 00:36:08 +0000 (02:36 +0200)
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
src/mathed/MathMacroTemplate.h

index e82de015bfddc0957ba69cd375a50565301acdda..62c681be826a61c125edd917ce8eb0f7a2b8d255 100644 (file)
@@ -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_) {
index 61f82e9d947d270b399a947eb2a11febd30b6955..0bb3d4db0be430b2be23042a2a58ccd205a7e09f 100644 (file)
@@ -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;
        ///