[LyX/master] Fix crash with info inset and dialogs
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Mon Feb 6 19:41:01 UTC 2023
commit 17e60e2e8559e5b702189c82a5a746b9f41cd219
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date: Mon Feb 6 21:34:08 2023 +0100
Fix crash with info inset and dialogs
See the thread
2.4 Crash (was: Updated LaTeXConfig.lyx (bxjsclasses added))
on lyx-devel (26/01/2023).
The backtrace imply a problem like:
1/ metrics are computed for some info inset
2/ the info inset is regenerated (and thus the paragraph it held is now invalid)
3/ We draw the inset and because of the new (disabled by default)
bookmark display code, we access the id() of the invalid paragraph.
4/ boom!
To fix the issue, introduce a new boolean member that indicates when
the Row object of the metrics should not be used. In this case, the
draw() method returns early.
---
src/insets/InsetInfo.cpp | 8 +++++++-
src/insets/InsetInfo.h | 2 ++
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp
index 46d656c..f2d3b93 100644
--- a/src/insets/InsetInfo.cpp
+++ b/src/insets/InsetInfo.cpp
@@ -467,7 +467,7 @@ string InsetInfoParams::infoType() const
InsetInfo::InsetInfo(Buffer * buf, string const & info)
- : InsetCollapsible(buf), initialized_(false)
+ : InsetCollapsible(buf), initialized_(false), dirty_(true)
{
params_.type = InsetInfoParams::UNKNOWN_INFO;
params_.force_ltr = false;
@@ -779,15 +779,19 @@ void InsetInfo::metrics(MetricsInfo & mi, Dimension & dim) const
{
const_cast<InsetInfo *>(this)->build();
InsetCollapsible::metrics(mi, dim);
+ dirty_ = false;
}
void InsetInfo::draw(PainterInfo & pi, int x, int y) const
{
+ if (dirty_)
+ return;
Changer chg = changeVar(lyxrc.mark_foreign_language, false);
InsetCollapsible::draw(pi, x, y);
}
+
void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted)
{
@@ -1235,6 +1239,8 @@ void InsetInfo::build()
}
}
+ // indicate that metrics are not usable anymore
+ dirty_ = true;
// Just to do something with that string
LYXERR(Debug::INFO, "info inset text: " << gui);
}
diff --git a/src/insets/InsetInfo.h b/src/insets/InsetInfo.h
index 3531b41..17d60e2 100644
--- a/src/insets/InsetInfo.h
+++ b/src/insets/InsetInfo.h
@@ -236,6 +236,8 @@ private:
void build();
///
bool initialized_;
+ /// true when metrics Row object should not be used
+ mutable bool dirty_;
///
InsetInfoParams params_;
///
More information about the lyx-cvs
mailing list