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
This commit is contained in:
Richard Heck 2011-12-03 22:42:09 +00:00
parent 43c09d7234
commit 210a440609
5 changed files with 33 additions and 7 deletions

View File

@ -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;
}

View File

@ -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 {

View File

@ -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();

View File

@ -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;
}

View File

@ -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;