From 210a440609df23bf48ca1b469cbead7e445e8b6d Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sat, 3 Dec 2011 22:42:09 +0000 Subject: [PATCH] Attempt to fix #7673 in a more "interesting" way than in branch (where we will be cautious, of course). The problem was that we were issuing the Buffer::changed() signal before we did updateBuffer(), and this caused an inconsistency. The idea here is to defer issuing this signal until we call processUpdateFlags(). We know we need a redraw if we've deleted a whole paragraph. This should work properly, so long as checkDepm is called from within the dispatch mechanism. There may, however, be other paths, and I've noted one explicitly with a FIXME in Text2.cpp. I've tested a few different variations, however, and I haven't seen any problems. But if we do run into problems, we can go ahead and do the update there that we were previously doing in checkDepm itself. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40352 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 2 +- src/Cursor.cpp | 9 +++++++-- src/Cursor.h | 2 ++ src/Text2.cpp | 3 +++ src/Text3.cpp | 24 ++++++++++++++++++++---- 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 139b99796c..f43cd7363c 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2410,7 +2410,7 @@ bool BufferView::checkDepm(Cursor & cur, Cursor & old) d->cursor_ = cur; cur.forceBufferUpdate(); - buffer_.changed(true); + cur.screenUpdateFlags(Update::Force); return true; } diff --git a/src/Cursor.cpp b/src/Cursor.cpp index b20e981b32..fb4988f787 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1968,8 +1968,12 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded) updateNeeded |= bv().checkDepm(dummy, *this); updateTextTargetOffset(); - if (updateNeeded) + if (updateNeeded) { forceBufferUpdate(); + // DEPM may have requested a screen update + this->screenUpdateFlags( + this->screenUpdate() | dummy.screenUpdate()); + } } return false; } @@ -1994,7 +1998,8 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded) ++dummy.pos(); if (bv().checkDepm(dummy, old)) { updateNeeded = true; - // Make sure that cur gets back whatever happened to dummy (Lgb) + // Make sure that cur gets back whatever happened to dummy (Lgb) + // This will include any screen update requested by DEPM operator=(dummy); } } else { diff --git a/src/Cursor.h b/src/Cursor.h index a7111c2908..0d74419678 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -247,6 +247,8 @@ public: * Not using noScreenUpdate() should never be wrong. */ void noScreenUpdate() const; + /// + Update::flags screenUpdate() const { return disp_.screenUpdate(); } /// fix cursor in circumstances that should never happen. /// \retval true if a fix occured. bool fixIfBroken(); diff --git a/src/Text2.cpp b/src/Text2.cpp index 14b03cfec5..199790cf2a 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -535,6 +535,9 @@ bool Text::setCursor(Cursor & cur, pit_type par, pos_type pos, bool const update_needed = !tm.contains(par); Cursor old = cur; setCursorIntern(cur, par, pos, setfont, boundary); + // FIXME There is a chance that we'll miss a screen update here. + // If so, then do DEPM and then check if cur wants an update and + // go ahead and do it, if so. return cur.bv().checkDepm(cur, old) || update_needed; } diff --git a/src/Text3.cpp b/src/Text3.cpp index 96fa1af10d..4c1d07bf46 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -630,8 +630,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // provide it with two different cursors. Cursor dummy = cur; dummy.pos() = dummy.pit() = 0; - if (cur.bv().checkDepm(dummy, cur)) + if (cur.bv().checkDepm(dummy, cur)) { cur.forceBufferUpdate(); + // DEPM may have requested a screen update + cur.screenUpdateFlags( + cur.screenUpdate() | dummy.screenUpdate()); + } } } break; @@ -657,8 +661,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) Cursor dummy = cur; dummy.pos() = cur.lastpos(); dummy.pit() = cur.lastpit(); - if (cur.bv().checkDepm(dummy, cur)) + if (cur.bv().checkDepm(dummy, cur)) { cur.forceBufferUpdate(); + // DEPM may have requested a screen update + cur.screenUpdateFlags( + cur.screenUpdate() | dummy.screenUpdate()); + } } } break; @@ -841,8 +849,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // provide it with two different cursors. Cursor dummy = cur; dummy.pos() = dummy.pit() = 0; - if (cur.bv().checkDepm(dummy, cur)) + if (cur.bv().checkDepm(dummy, cur)) { cur.forceBufferUpdate(); + // DEPM may have requested a screen update + cur.screenUpdateFlags( + cur.screenUpdate() | dummy.screenUpdate()); + } } } break; @@ -891,8 +903,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) Cursor dummy = cur; dummy.pos() = cur.lastpos(); dummy.pit() = cur.lastpit(); - if (cur.bv().checkDepm(dummy, cur)) + if (cur.bv().checkDepm(dummy, cur)) { cur.forceBufferUpdate(); + // DEPM may have requested a screen update + cur.screenUpdateFlags( + cur.screenUpdate() | dummy.screenUpdate()); + } } } break; -- 2.39.2