commit 00c39208ac653ba0a2decebcc3d37e0a0956b88b
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Wed Feb 22 18:09:03 2023 +0100

    At metrics time, store paragraph id too
    
    Instead of actually fixing the messiness of InsetInfo, let's just fix
    the symptom and avoid the access to Paragraph::id() that was crashing
    LyX every time updateBuffer/validate/metrics/draw did not happen in
    the right order.
    
    Fixes bug #12639.
---
 src/ParagraphMetrics.cpp |    2 +-
 src/ParagraphMetrics.h   |    4 ++++
 src/TextMetrics.cpp      |    2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/ParagraphMetrics.cpp b/src/ParagraphMetrics.cpp
index 46f2edc..31b31a2 100644
--- a/src/ParagraphMetrics.cpp
+++ b/src/ParagraphMetrics.cpp
@@ -42,7 +42,7 @@ namespace lyx {
 
 
 ParagraphMetrics::ParagraphMetrics(Paragraph const & par) :
-       position_(-1), par_(&par)
+       position_(-1), id_(par.id()), par_(&par)
 {}
 
 
diff --git a/src/ParagraphMetrics.h b/src/ParagraphMetrics.h
index 1d690aa..e0d9ce0 100644
--- a/src/ParagraphMetrics.h
+++ b/src/ParagraphMetrics.h
@@ -72,11 +72,15 @@ public:
        ///
        int position() const { return position_; }
        void setPosition(int position);
+       ///
+       int id() const { return id_; }
 
 private:
        ///
        int position_;
        ///
+       int id_;
+       ///
        mutable RowList rows_;
        /// cached dimensions of paragraph
        Dimension dim_;
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 2dea92b..995b09c 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1986,7 +1986,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, 
pit_type const pit, int const
                swap(pi.leftx, pi.rightx);
 
        BookmarksSection::BookmarkPosList bpl =
-               
theSession().bookmarks().bookmarksInPar(bv_->buffer().fileName(), 
pm.par().id());
+               
theSession().bookmarks().bookmarksInPar(bv_->buffer().fileName(), pm.id());
 
        for (size_t i = 0; i != nrows; ++i) {
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to