]> git.lyx.org Git - features.git/commitdiff
Use parMetrics to access the par_metrics_ map
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 12 Feb 2018 16:11:09 +0000 (17:11 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 20 Feb 2018 14:02:35 +0000 (15:02 +0100)
In cursorY, it is dangerous to access par_petrics_[0], since one does
not know whether metrics have been computed for this paragraph (which
may be off-screen).

It is safer to use parMetrics(0), that will compute the paragraph
metrics as needed.

Fixes bug #8120.

(cherry picked from commit a25b48f86cdde98bbd5f8ece06c6bf2f12ee84db)

src/TextMetrics.cpp
status.23x

index e7bd6190e28759405821df6cda72e4d245ae5cfa..5d4b88d6045747d29f2c8b8691799de19e134870 100644 (file)
@@ -1502,14 +1502,14 @@ int TextMetrics::cursorX(CursorSlice const & sl,
 int TextMetrics::cursorY(CursorSlice const & sl, bool boundary) const
 {
        //lyxerr << "TextMetrics::cursorY: boundary: " << boundary << endl;
-       ParagraphMetrics const & pm = par_metrics_[sl.pit()];
+       ParagraphMetrics const & pm = parMetrics(sl.pit());
        if (pm.rows().empty())
                return 0;
 
        int h = 0;
-       h -= par_metrics_[0].rows()[0].ascent();
+       h -= parMetrics(0).rows()[0].ascent();
        for (pit_type pit = 0; pit < sl.pit(); ++pit) {
-               h += par_metrics_[pit].height();
+               h += parMetrics(pit).height();
        }
        int pos = sl.pos();
        if (pos && boundary)
index b6c4427c497f6ec5a435afb641128aa680e6dd5f..726bcf464405042cb783a1c781b9305e975037d5 100644 (file)
@@ -58,6 +58,8 @@ What's new
 
 * USER INTERFACE
 
+- Fix crash with server-get-xy and tall inset (bug 8120).
+
 - Improve Undo for operations that act on several buffers (bug 10823).
 
 - Improve rendering of square roots in math editor (bug 10814).