Use parMetrics to access the par_metrics_ map

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.
This commit is contained in:
Jean-Marc Lasgouttes 2018-02-12 17:11:09 +01:00
parent 24fd7d2bac
commit a25b48f86c

View 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)