[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jul 24 12:43:14 UTC 2018
sw/source/core/text/porlay.cxx | 25 ++++++++++++++++++++++++-
sw/source/core/text/porlay.hxx | 1 +
2 files changed, 25 insertions(+), 1 deletion(-)
New commits:
commit 8347f43707ca1dc4f79dbaf3d5136f35067a6e6d
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jul 24 11:40:33 2018 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jul 24 14:42:50 2018 +0200
forcepoint#52 flatten deep recursive delete of SwLineLayout
Change-Id: I36d995062f4677ae900009d1eb5d48b906a4b36f
Reviewed-on: https://gerrit.libreoffice.org/57910
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index e6b2ea0ee5a1..843d09c231b8 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -171,6 +171,29 @@ static bool lcl_HasStrongLTR ( const OUString& rText, sal_Int32 nStart, sal_Int
return false;
}
+// This is (meant to be) functionally equivalent to 'delete m_pNext' where
+// deleting a SwLineLayout recursively deletes the owned m_pNext SwLineLayout.
+//
+// Here, instead of using a potentially deep stack, iterate over all the
+// SwLineLayouts that would be deleted recursively and delete them linearly
+void SwLineLayout::DeleteNext()
+{
+ if (!m_pNext)
+ return;
+ std::vector<SwLineLayout*> aNexts;
+ SwLineLayout* pNext = m_pNext;
+ do
+ {
+ aNexts.push_back(pNext);
+ SwLineLayout* pLastNext = pNext;
+ pNext = pNext->GetNext();
+ pLastNext->SetNext(nullptr);
+ }
+ while (pNext);
+ for (auto a : aNexts)
+ delete a;
+}
+
// class SwLineLayout: This is the layout of a single line, which is made
// up of its dimension, the character count and the word spacing in the line.
// Line objects are managed in an own pool, in order to store them continuously
@@ -178,7 +201,7 @@ static bool lcl_HasStrongLTR ( const OUString& rText, sal_Int32 nStart, sal_Int
SwLineLayout::~SwLineLayout()
{
Truncate();
- delete m_pNext;
+ DeleteNext();
if( pBlink )
pBlink->Delete( this );
m_pLLSpaceAdd.reset();
diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx
index 1ebf00cc0c0d..bffa35c692e8 100644
--- a/sw/source/core/text/porlay.hxx
+++ b/sw/source/core/text/porlay.hxx
@@ -102,6 +102,7 @@ private:
SwTwips GetHangingMargin_() const;
+ void DeleteNext();
public:
// From SwLinePortion
virtual SwLinePortion *Insert( SwLinePortion *pPortion ) override;
More information about the Libreoffice-commits
mailing list