Le 25/11/2020 à 15:35, Scott Kostyshak a écrit :
I see a couple of changes in behavior in advanced find that can be
reproduced with the Welcome.lyx file (I attached it for convenience).

1. In advanced find, put "a" in the find area and "c" in the replace
    area and do "Replace all". It takes about 10 seconds with 2.3.0, and
    about 25 seconds with master. I remember when testing before that
    advanced find was much faster than 2.3.0, so if this is just a weird
    "worst case" scenario, then I think that's fine.

Try again, I updated the layout files, it seems to make a big difference to me. Then we have to know why Adv F&R has to read the class files at all (using cut and paste, maybe?)

2. In 2.3.0, there are more workarea updates. This way, the user can see
    what is being replaced and where. In master, there is only one work
    area update at the end. This seems like an improvement in theory, but
    since the advanced find takes a while, it is kind of nice to watch it
    so that we know it is not stuck and can get an idea of the progress.
    In master, it is strange to see toolbar buttons being enabled and
    disabled (based on where the invisible cursor is) and the scrollbar
    moving, but not to see the cursor moving and the work area updates. I
    don't have a preference on this. I just mention it in case the change
    was not intended.

With the attached patch, the toolbar is not updated anymore. The scrollbar still moves, though, and acts as a sort of progression bar.

The priority should be on making things fast, though.

JMarc
>From 0f0318799e6bdf0faf72fe2afd551f26e93ab86f Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Mon, 21 Dec 2020 19:21:45 +0100
Subject: [PATCH] Do not update Toolbar when bufferview is not ready

During a long operation, the screen is not updated. However, during a
long Adv F&R, the toolbar icons change as the cursor moves along the
document.

With this change, a new BufferView::busy() method abstracts whether
there is an active open undo group.

Do not update the Toolbar when the buffer view is busy.
---
 src/Buffer.cpp                   | 6 ++++++
 src/Buffer.h                     | 2 ++
 src/BufferView.cpp               | 7 +++++++
 src/BufferView.h                 | 2 ++
 src/frontends/qt/GuiToolbar.cpp  | 4 ++++
 src/frontends/qt/GuiWorkArea.cpp | 7 +++----
 6 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index ddce2db44e..f5f568b6d1 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -800,6 +800,12 @@ Undo & Buffer::undo()
 }
 
 
+Undo const & Buffer::undo() const
+{
+	return d->undo_;
+}
+
+
 void Buffer::setChild(DocIterator const & dit, Buffer * child)
 {
 	d->children_positions[child] = dit;
diff --git a/src/Buffer.h b/src/Buffer.h
index 9adc7172c8..0c4ee69a41 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -646,6 +646,8 @@ public:
 
 	///
 	Undo & undo();
+	///
+	Undo const & undo() const;
 
 	/// This function is called when the buffer is changed.
 	void changed(bool update_metrics) const;
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 758a9928f1..3e39139c05 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1066,6 +1066,13 @@ static Change::Type lookupChangeType(DocIterator const & dit, bool outer = false
 }
 
 
+bool BufferView::busy() const
+{
+	// if there is an undo group, we are changing the document
+	return buffer().undo().activeUndoGroup();
+}
+
+
 bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
 {
 	FuncCode const act = cmd.action();
diff --git a/src/BufferView.h b/src/BufferView.h
index 1b76da2711..0cdd6fae8c 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -363,6 +363,8 @@ public:
 	bool clickableInset() const;
 	///
 	void makeDocumentClass();
+	/// return true is the view is not ready to be displayed
+	bool busy() const;
 
 private:
 	/// noncopyable
diff --git a/src/frontends/qt/GuiToolbar.cpp b/src/frontends/qt/GuiToolbar.cpp
index 5600f4a74f..7783b76eb0 100644
--- a/src/frontends/qt/GuiToolbar.cpp
+++ b/src/frontends/qt/GuiToolbar.cpp
@@ -549,6 +549,10 @@ void GuiToolbar::add(ToolbarItem const & item)
 
 void GuiToolbar::update(int context)
 {
+	// if the bufferview is currently changing, do not update the toolbar
+	if (owner().currentBufferView() && owner().currentBufferView()->busy())
+		return;
+
 	if (visibility_ & Toolbars::AUTO) {
 		setVisible(visibility_ & context & Toolbars::ALLOWAUTO);
 		if (isVisible() && commandBuffer() && (context & Toolbars::MINIBUFFER_FOCUS))
diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index 3a2a362f09..9e5fc3ac4b 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -37,7 +37,6 @@
 #include "LyXVC.h"
 #include "Text.h"
 #include "TextMetrics.h"
-#include "Undo.h"
 #include "version.h"
 
 #include "support/convert.h"
@@ -320,7 +319,7 @@ void GuiWorkArea::startBlinkingCaret()
 
 	// Don't start blinking if the cursor isn't on screen, unless we
 	// are not ready to know whether the cursor is on screen.
-	if (!d->buffer_view_->buffer().undo().activeUndoGroup()
+	if (!d->buffer_view_->busy()
 	    && !d->buffer_view_->caretInView())
 		return;
 
@@ -507,7 +506,7 @@ 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()
+	if (buffer_view_->busy()
 	    || !buffer_view_->caretInView())
 		return;
 
@@ -1231,7 +1230,7 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
 	// Do not trigger the painting machinery if we are not ready (see
 	// bug #10989). The second test triggers when in the middle of a
 	// dispatch operation.
-	if (view().busy() || d->buffer_view_->buffer().undo().activeUndoGroup()) {
+	if (view().busy() || d->buffer_view_->busy()) {
 		// Since macOS has turned the screen black at this point, our
 		// backing store has to be copied to screen (this is a no-op
 		// except on macOS).
-- 
2.27.0

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

Reply via email to