Avoid crash when trying to handle FitCursor

It is better to handle SinglePar before FitCursor, since the later
requires correct metrics at cursor position.

Fixes bug #11139 and probably #11125.
This commit is contained in:
Jean-Marc Lasgouttes 2018-05-11 11:27:26 +02:00
parent 88c76ce4d2
commit 7f83d26934

View File

@ -477,7 +477,8 @@ string flagsAsString(Update::flags flags)
return string((flags & Update::FitCursor) ? "FitCursor " : "") return string((flags & Update::FitCursor) ? "FitCursor " : "")
+ ((flags & Update::Force) ? "Force " : "") + ((flags & Update::Force) ? "Force " : "")
+ ((flags & Update::ForceDraw) ? "ForceDraw " : "") + ((flags & Update::ForceDraw) ? "ForceDraw " : "")
+ ((flags & Update::SinglePar) ? "SinglePar " : ""); + ((flags & Update::SinglePar) ? "SinglePar " : "")
+ ((flags & Update::Decoration) ? "Decoration " : "");
} }
} }
@ -503,6 +504,16 @@ void BufferView::processUpdateFlags(Update::flags flags)
updateMetrics(flags); updateMetrics(flags);
} }
// Detect whether we can only repaint a single paragraph.
// We handle this before FitCursor because the later will require
// correct metrics at cursor position.
if (!(flags & Update::ForceDraw)) {
if (singleParUpdate())
flags = flags | Update::SinglePar;
else
updateMetrics(flags);
}
// Then make sure that the screen contains the cursor if needed // Then make sure that the screen contains the cursor if needed
if (flags & Update::FitCursor) { if (flags & Update::FitCursor) {
if (needsFitCursor()) { if (needsFitCursor()) {
@ -513,14 +524,6 @@ void BufferView::processUpdateFlags(Update::flags flags)
flags = flags & ~Update::FitCursor; flags = flags & ~Update::FitCursor;
} }
// Finally detect whether we can only repaint a single paragraph
if (!(flags & Update::ForceDraw)) {
if (singleParUpdate())
flags = flags | Update::SinglePar;
else
updateMetrics(flags);
}
// Add flags to the the update flags. These will be reset to None // Add flags to the the update flags. These will be reset to None
// after the redraw is actually done // after the redraw is actually done
d->update_flags_ = d->update_flags_ | flags; d->update_flags_ = d->update_flags_ | flags;