diff options
author | Sebastian Geerken <devnull@localhost> | 2012-12-16 11:37:22 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2012-12-16 11:37:22 +0100 |
commit | 7a32cc6e10394d5610dc1e1a2f5730720ee54929 (patch) | |
tree | 5ccdf66338c0a09f53dcd024c905407e2b1d17ee /dw/textblock_linebreaking.cc | |
parent | 2382e62f0e66398f486bb1e9ec7b42b62f34bbef (diff) |
Fixed an endless loop.
Diffstat (limited to 'dw/textblock_linebreaking.cc')
-rw-r--r-- | dw/textblock_linebreaking.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 6cadca26..02c42339 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -1082,9 +1082,21 @@ void Textblock::fillParagraphs () else firstWordOfLine = 0; - // If there are no paragraphs yet, findParagraphOfWord will return - // -1: use 0 then instead. - int parNo = misc::max (0, findParagraphOfWord (firstWordOfLine)); + int parNo; + if (paragraphs->size() > 0 && + firstWordOfLine > paragraphs->getLastRef()->firstWord) + // A special case: the paragraphs list has been partly built, but + // not yet the paragraph containing the word in question. In + // this case, only the rest of the paragraphs list must be + // constructed. (Without this check, findParagraphOfWord would + // return -1 in this case, so that all paragraphs would be + // rebuilt.) + parNo = paragraphs->size (); + else + // If there are no paragraphs yet, findParagraphOfWord will return + // -1: use 0 then instead. + parNo = misc::max (0, findParagraphOfWord (firstWordOfLine)); + paragraphs->setSize (parNo); int firstWord; |