commit a56e3463eaae4aa365a4009cf88af859c575b325
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Fri Jun 26 10:39:14 2026 +0200
When a macro template is changed compute all new previews at once
When a math macro template is changed, it may be necessary to update
the previews of math formulas after this point.
However, the current code runs the preview machinery for each formula
separately instead of accumulating snippets and computing all the
previews at the same time.
Thanks to Claude for the analysis.
Fixes bug #13342.
(cherry picked from commit 4714aec6b4b02ccf01ac928371ed86ae5f4a39c6)
---
src/mathed/InsetMathHull.h | 9 ++++-----
src/mathed/InsetMathMacroTemplate.cpp | 11 ++++++-----
status.25x | 2 ++
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h
index b5cfe92f03..8c061e1d1d 100644
--- a/src/mathed/InsetMathHull.h
+++ b/src/mathed/InsetMathHull.h
@@ -166,6 +166,10 @@ public:
void notifyMouseSelectionDone(Cursor & cur) override;
///
bool insetAllowed(InsetCode code) const override;
+ /// Prepare the preview if preview is enabled.
+ /// \param forexport: whether this is intended for export
+ /// If so, we ignore LyXRC and wait for the image to be generated.
+ void preparePreview(DocIterator const & pos, bool forexport = false)
const;
///
void addPreview(DocIterator const & inset_pos,
graphics::PreviewLoader &) const override;
@@ -212,11 +216,6 @@ protected:
private:
Inset * clone() const override;
- /// Prepare the preview if preview is enabled.
- /// \param forexport: whether this is intended for export
- /// If so, we ignore LyXRC and wait for the image to be generated.
- void preparePreview(DocIterator const & pos,
- bool forexport = false) const;
/// like reloadPreview, but forces load
/// used by image export
void loadPreview(DocIterator const & pos) const;
diff --git a/src/mathed/InsetMathMacroTemplate.cpp
b/src/mathed/InsetMathMacroTemplate.cpp
index 15b115bcd3..d4727531c8 100644
--- a/src/mathed/InsetMathMacroTemplate.cpp
+++ b/src/mathed/InsetMathMacroTemplate.cpp
@@ -36,6 +36,8 @@
#include "frontends/Painter.h"
+#include "graphics/PreviewLoader.h"
+
#include "insets/RenderPreview.h"
#include "support/lassert.h"
@@ -855,14 +857,13 @@ void fixMacroInstances(Cursor & cur, DocIterator const &
inset_pos,
if (!preview_hulls.empty()) {
// reload the scheduled previews
- set<DocIterator>::const_iterator sit = preview_hulls.begin();
- set<DocIterator>::const_iterator end = preview_hulls.end();
- for (; sit != end; ++sit) {
+ for (auto const & sit : preview_hulls) {
InsetMathHull * inset_hull =
- sit->nextInset()->asInsetMath()->asHullInset();
+ sit.nextInset()->asInsetMath()->asHullInset();
LBUFERR(inset_hull);
- inset_hull->reloadPreview(*sit);
+ inset_hull->preparePreview(sit);
}
+ inset_pos.buffer()->loader()->startLoading();
cur.screenUpdateFlags(Update::Force);
}
}
diff --git a/status.25x b/status.25x
index cd8097914d..66f8829fb8 100644
--- a/status.25x
+++ b/status.25x
@@ -37,6 +37,8 @@ What's new
- Avoid big delays when selecting a macro definition (bug 13338).
+- When a macro is modified, make previews update faster (bug 13342).
+
* DOCUMENTATION AND LOCALIZATION
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs