X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FMathMacroTemplate.cpp;h=2989e2be5ce01ba25c5aab5ccabdf091308552d4;hb=981e958b9d63930c83b1adced65b75b3d857ac97;hp=3de1fade25004d378d1aca5efef4f8a6815f0ffc;hpb=14cbb6cb3d8eec273d69b6d0744787688fd1e4ef;p=lyx.git diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp index 3de1fade25..2989e2be5c 100644 --- a/src/mathed/MathMacroTemplate.cpp +++ b/src/mathed/MathMacroTemplate.cpp @@ -47,6 +47,7 @@ #include "support/docstream.h" #include "support/lstrings.h" +#include #include using namespace std; @@ -736,7 +737,8 @@ public: /// AddRemoveMacroInstanceFix(int n, bool insert) : n_(n), insert_(insert) {} /// - void operator()(MathMacro * macro) { + void operator()(MathMacro * macro) + { if (macro->folded()) { if (insert_) macro->insertArgument(n_); @@ -760,7 +762,8 @@ public: /// OptionalsMacroInstanceFix(int optionals) : optionals_(optionals) {} /// - void operator()(MathMacro * macro) { + void operator()(MathMacro * macro) + { macro->setOptionals(optionals_); } @@ -791,18 +794,15 @@ void fixMacroInstances(Cursor & cur, DocIterator const & inset_pos, // remember hull to trigger preview reload DocIterator hull(dit.buffer()); bool preview_reload_needed = false; + set preview_hulls; // iterate over all positions until macro is redefined for (; dit; dit.forwardPos()) { // left the outer hull? if (!hull.empty() && dit.depth() == hull.depth()) { - // reload the preview if necessary + // schedule reload of the preview if necessary if (preview_reload_needed) { - InsetMathHull * inset_hull = - hull.nextInset()->asInsetMath()->asHullInset(); - LASSERT(inset_hull, /**/); - inset_hull->reloadPreview(hull); - cur.screenUpdateFlags(Update::Force); + preview_hulls.insert(hull); preview_reload_needed = false; } hull.clear(); @@ -838,6 +838,19 @@ void fixMacroInstances(Cursor & cur, DocIterator const & inset_pos, preview_reload_needed = true; } } + + if (!preview_hulls.empty()) { + // reload the scheduled previews + set::const_iterator sit = preview_hulls.begin(); + set::const_iterator end = preview_hulls.end(); + for (; sit != end; ++sit) { + InsetMathHull * inset_hull = + sit->nextInset()->asInsetMath()->asHullInset(); + LASSERT(inset_hull, /**/); + inset_hull->reloadPreview(*sit); + } + cur.screenUpdateFlags(Update::Force); + } } @@ -1079,6 +1092,7 @@ bool MathMacroTemplate::getStatus(Cursor & /*cur*/, FuncRequest const & cmd, flag.setEnabled(numargs_ < 9); break; + case LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM: case LFUN_MATH_MACRO_REMOVE_PARAM: { int num = numargs_; if (arg.size() != 0)