From 7808a20e5cd8bb2f80af36bab3036fad7053e6f0 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 10 Mar 2017 19:54:15 +0100 Subject: [PATCH] Fix crash when adding newline at the end of a paragraph This is a regression at b0673bd1. The code referred to row.pit(), which was not correctly initialized in this case. The bug does not exist in master, since the code in redoParagraph has been cleaned-up and row.pit() is always correct. Two corrective measures are taken, each of which would fix the bug: - do not use row.pit() in breakRow, but directly the pit parameter. - initialize row.pit() correctly in the faulty case. --- src/TextMetrics.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 280c90a3df..8f62eedcaa 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -481,6 +481,7 @@ bool TextMetrics::redoParagraph(pit_type const pit) pm.rows().push_back(Row()); Row & row = pm.rows()[row_index]; row.pos(first); + row.pit(pit); breakRow(row, right_margin, pit); setRowHeight(row, pit); row.setChanged(false); @@ -932,8 +933,8 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit // if the row is too large, try to cut at last separator. In case // of success, reset indication that the row was broken abruptly. - int const next_width = max_width_ - leftMargin(max_width_, row.pit(), row.endpos()) - - rightMargin(row.pit()); + int const next_width = max_width_ - leftMargin(max_width_, pit, row.endpos()) + - rightMargin(pit); row.shortenIfNeeded(body_pos, width, next_width); row.right_boundary(!row.empty() && row.endpos() < end