mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 02:28:35 +00:00
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:
parent
9680f392b0
commit
6ed292122d
@ -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_) {
|
||||
|
@ -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;
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user