commit 7808a20e5cd8bb2f80af36bab3036fad7053e6f0
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Fri Mar 10 19:54:15 2017 +0100
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 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 280c90a..8f62eed 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