[LyX/2.3.x] Do not compute caret geometry when we are not ready to do so.

Jean-Marc Lasgouttes lasgouttes at lyx.org
Thu Apr 9 10:39:57 UTC 2020


commit b7f6b979d0f889f08e735f35378bb20ba3788b4b
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Sat Apr 4 18:02:04 2020 +0200

    Do not compute caret geometry when we are not ready to do so.
    
    This avoid crashes with invalid cache.
    
    Fixes bug #11763.
---
 src/frontends/qt4/GuiWorkArea.cpp |   21 +++++++++++++++------
 status.23x                        |    2 ++
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp
index e16ea16..95cff6d 100644
--- a/src/frontends/qt4/GuiWorkArea.cpp
+++ b/src/frontends/qt4/GuiWorkArea.cpp
@@ -443,12 +443,16 @@ void GuiWorkArea::startBlinkingCaret()
 	if (view().busy())
 		return;
 
-	Point p;
-	int h = 0;
-	d->buffer_view_->caretPosAndHeight(p, h);
-	// Don't start blinking if the cursor isn't on screen.
-	if (!d->buffer_view_->cursorInView(p, h))
-		return;
+	// we cannot update geometry if not ready and we do not need to if
+	// caret is not in view.
+	if (!d->buffer_view_->buffer().undo().activeUndoGroup()) {
+		Point p;
+		int h = 0;
+		d->buffer_view_->caretPosAndHeight(p, h);
+		// Don't start blinking if the cursor isn't on screen.
+		if (!d->buffer_view_->cursorInView(p, h))
+			return;
+	}
 
 	d->showCaret();
 
@@ -611,6 +615,11 @@ void GuiWorkArea::Private::resizeBufferView()
 
 void GuiWorkArea::Private::updateCaretGeometry()
 {
+	// we cannot update geometry if not ready and we do not need to if
+	// caret is not in view.
+	if (buffer_view_->buffer().undo().activeUndoGroup())
+		return;
+
 	Point point;
 	int h = 0;
 	buffer_view_->caretPosAndHeight(point, h);
diff --git a/status.23x b/status.23x
index f15bfef..70faf48 100644
--- a/status.23x
+++ b/status.23x
@@ -98,6 +98,8 @@ What's new
 - Preserve paragarph spacing when breaking a paragraph at the start
   (bug 11817).
 
+- Avoid crash in some cases where a dialog is shown during operation
+  (bug 11763).
 
 * INTERNALS
 


More information about the lyx-cvs mailing list