]> git.lyx.org Git - features.git/commitdiff
Avoid crash when trying to handle FitCursor
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 11 May 2018 09:27:26 +0000 (11:27 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 13 May 2018 22:10:45 +0000 (00:10 +0200)
It is better to handle SinglePar before FitCursor, since the later
requires correct metrics at cursor position.

Fixes bug #11139 and probably #11125.

(cherry picked from commit 7f83d26934e50e3d83e254b0f9ab847d957053f7)

src/BufferView.cpp

index da09fcd273c1d3976f9dcadf51e89eead460a497..588dea74b47ea7aecb18c6bda57c232bb2d3148c 100644 (file)
@@ -461,7 +461,8 @@ string flagsAsString(Update::flags flags)
        return string((flags & Update::FitCursor) ? "FitCursor " : "")
                + ((flags & Update::Force) ? "Force " : "")
                + ((flags & Update::ForceDraw) ? "ForceDraw " : "")
-               + ((flags & Update::SinglePar) ? "SinglePar " : "");
+               + ((flags & Update::SinglePar) ? "SinglePar " : "")
+               + ((flags & Update::Decoration) ? "Decoration " : "");
 }
 
 }
@@ -487,6 +488,16 @@ void BufferView::processUpdateFlags(Update::flags 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
        if (flags & Update::FitCursor) {
                if (needsFitCursor()) {
@@ -497,14 +508,6 @@ void BufferView::processUpdateFlags(Update::flags flags)
                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
        // after the redraw is actually done
        d->update_flags_ = d->update_flags_ | flags;