Le 11/01/2025 à 23:53, Pavel Sanda a écrit :
checkout the commit 8a181862d
0) load the file I sent you earlier
1) set cursor on line 1.4
2) scroll 1.4 it to be the last line of the screen
3) close lyx
4) remove figure cache
5) relaunch lyx & wait for figures on screen to load
    if not crash goto 2

Once you get crash, you have longer serie of crashes with the above recipy  
(like order of 3-6)
Once it survives, you have longer serie of ok loads with the above recipy (like 
order of 2-5)
In total it averages to about 75% of crash cases.

Could you check whether you can still reproduce with the patch below?

JMarc

From 74dd6b1380df1c0f5b8bb05dca5ac878b0293630 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Sat, 8 Feb 2025 21:09:23 +0100
Subject: [PATCH] Avoid unnecessary creation of a row around caret position.

When trying to see whether the caret has affected a row, do not create
this row (with redoParagraph) if it did not exist.
---
 src/BufferView.cpp | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 4b1403478d..668c0a1c92 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -3815,22 +3815,26 @@ void BufferView::draw(frontend::Painter & pain, bool paint_caret)
 	}
 
 	// If a caret has to be painted, mark its text row as dirty to
-	//make sure that it will be repainted on next redraw.
+	// make sure that it will be repainted on next redraw.
 	/* FIXME: investigate whether this can be avoided when the cursor did not
 	 * move at all
 	 */
 	if (paint_caret) {
 		Cursor cur(d->cursor_);
 		while (cur.depth() > 1) {
-			if (!cur.inTexted())
-				break;
-			TextMetrics const & tm = textMetrics(cur.text());
-			if (d->caret_geometry_.left >= tm.origin().x
-				&& d->caret_geometry_.right <= tm.origin().x + tm.dim().width())
-				break;
+			if (cur.inTexted()) {
+				TextMetrics const & tm = textMetrics(cur.text());
+				if (d->caret_geometry_.left >= tm.origin().x
+				    && d->caret_geometry_.right <= tm.origin().x + tm.dim().width())
+					break;
+			}
 			cur.pop();
 		}
-		cur.textRow().changed(true);
+		TextMetrics const & tm = textMetrics(cur.text());
+		if (tm.contains(cur.pit())) {
+			ParagraphMetrics const & pm = tm.parMetrics(cur.pit());
+			pm.getRow(cur.pos(), cur.boundary()).changed(true);
+		}
 	}
 }
 
-- 
2.45.2

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to