Code factoring: introduce BufferView::busy()

The WorkArea should not have to look at details of the undo stack.
No change intended.
This commit is contained in:
Jean-Marc Lasgouttes 2023-05-03 11:52:27 +02:00
parent dfc3db773a
commit 89db357cd6
5 changed files with 19 additions and 6 deletions

View File

@ -802,6 +802,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;

View File

@ -651,6 +651,8 @@ public:
///
Undo & undo();
///
Undo const & undo() const;
/// This function is called when the buffer is changed.
void changed(bool update_metrics) const;

View File

@ -3527,6 +3527,12 @@ void BufferView::checkCursorScrollOffset()
}
bool BufferView::busy() const
{
return buffer().undo().activeUndoGroup();
}
void BufferView::draw(frontend::Painter & pain, bool paint_caret)
{
if (height_ == 0 || width_ == 0)

View File

@ -339,6 +339,8 @@ public:
/// the shape of the caret
frontend::CaretGeometry const & caretGeometry() const;
/// Returns true when the BufferView is not ready for drawing
bool busy() const;
///
void draw(frontend::Painter & pain, bool paint_caret);

View File

@ -39,7 +39,6 @@
#include "LyXVC.h"
#include "Text.h"
#include "TextMetrics.h"
#include "Undo.h"
#include "version.h"
#include "support/convert.h"
@ -311,8 +310,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()
&& !d->buffer_view_->caretInView())
if (!d->buffer_view_->busy() && !d->buffer_view_->caretInView())
return;
d->showCaret();
@ -498,8 +496,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()
|| !buffer_view_->caretInView())
if (buffer_view_->busy() || !buffer_view_->caretInView())
return;
@ -1240,7 +1237,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 the screen may have turned black at this point, our
// backing store has to be copied to screen. This is a no-op
// except when our drawing strategy is "backingstore" (macOS,