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.
This commit is contained in:
Vincent van Ravesteijn 2013-10-11 23:36:56 +02:00
parent 9680f392b0
commit 6ed292122d
2 changed files with 4 additions and 8 deletions

View 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_) {

View 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;
///