summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-09-28 13:28:13 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-10-05 07:59:11 +0000
commitdabd6add51783f7b9fed502873dfa71beb936e96 (patch)
tree5154b501ef7a3d5e14eff067b7e0f872b4e53367
parenta47494d501294d17654afe0d692da10096f68822 (diff)
Resolves: tdf#93461 captions laid out behind images
regression from... commit 8a08f68669f9acfe98dadcca4af6519164a17000 Author: Mike <mikekaganski@hotmail.com> Date: Mon Apr 27 01:27:05 2015 +1000 tdf#66141: SwTxtFrm::FormatQuick(bool) endless loop If a line happens to be invisible (e.g. in too thin cell of a table) then aLine.FormatLine(nStart) returns nStart, and aLine.Insert( new SwLineLayout() ) is executed until OOM. keep the zero advance loop detection attempt, but allow the first insertion and disallow subsequent inserts Change-Id: I16380588220149cfd0ed0f835f08d2849180fece (cherry picked from commit f06508e2cfa7e833862b7e9ff3b2f79181672275) Reviewed-on: https://gerrit.libreoffice.org/18908 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/source/core/text/frmform.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 263c05fdcf88..7f863c6c2995 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -1909,12 +1909,20 @@ bool SwTextFrm::FormatQuick( bool bForceQuickFormat )
sal_Int32 nStart = GetOfst();
const sal_Int32 nEnd = GetFollow()
? GetFollow()->GetOfst() : aInf.GetText().getLength();
+
+ int nLoopProtection = 0;
do
{
- sal_Int32 nShift = aLine.FormatLine(nStart) - nStart;
- nStart += nShift;
- if ((nShift != 0) // Check for special case: line is invisible,
- // like in too thin table cell: tdf#66141
+ sal_Int32 nNewStart = aLine.FormatLine(nStart);
+ if (nNewStart == nStart)
+ ++nLoopProtection;
+ else
+ nLoopProtection = 0;
+ nStart = nNewStart;
+ const bool bWillEndlessInsert = nLoopProtection > 2;
+ SAL_WARN_IF(bWillEndlessInsert, "sw", "loop detection triggered");
+ if ((!bWillEndlessInsert) // Check for special case: line is invisible,
+ // like in too thin table cell: tdf#66141
&& (aInf.IsNewLine() || (!aInf.IsStop() && nStart < nEnd)))
aLine.Insert( new SwLineLayout() );
} while( aLine.Next() );