diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-06-02 18:16:15 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-06-22 15:37:06 +0200 |
commit | da1f030eec952dcd6d78ecd80a311b7b33320674 (patch) | |
tree | 035b1cc8ba7b467e7d4ec02463b7439eba0e8721 | |
parent | tdf#45589 sw: add tooltip to Formatting Aids dialog Bookmark label (diff) | |
download | core-da1f030eec952dcd6d78ecd80a311b7b33320674.tar.gz core-da1f030eec952dcd6d78ecd80a311b7b33320674.zip |
crashtesting: fix abi11870-2.odt assert in SwBookmarkPortion::Unchain()
This m_pPrevious pointer is a bad idea, should just use
FindPrevPortion() to find it, which shouldn't take that long to iterate
all the portions in the current line.
(regression from 4ce8120f1e53f7b81e653b01d141643013bc69ab)
Change-Id: Ibb5f2bb28d959958547ed27c51e5084cc746d642
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91622
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit f68749054f36f070310e70e2dbf0a11c496539c0)
-rw-r--r-- | sw/qa/extras/layout/data/abi11870-2.odt | bin | 0 -> 117386 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/text/itrform2.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/pormulti.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/text/porrst.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/text/porrst.hxx | 7 |
6 files changed, 15 insertions, 17 deletions
diff --git a/sw/qa/extras/layout/data/abi11870-2.odt b/sw/qa/extras/layout/data/abi11870-2.odt Binary files differnew file mode 100644 index 000000000000..b02bb85646aa --- /dev/null +++ b/sw/qa/extras/layout/data/abi11870-2.odt diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index ea4619f9c1bc..a6015fedaac3 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -3482,6 +3482,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116501) createDoc("tdf116501.odt"); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testAbi11870) +{ + //just care it doesn't assert + createDoc("abi11870-2.odt"); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf118719) { // Insert a page break. diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 8a906b4bf2e3..7901c10ccadd 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -1209,7 +1209,7 @@ SwLinePortion *SwTextFormatter::WhichFirstPortion(SwTextFormatInfo &rInf) assert(bookmark & SwScriptInfo::MarkKind::Point); mark = '|'; } - pPor = new SwBookmarkPortion(rInf.GetLast(), mark); + pPor = new SwBookmarkPortion(mark); } } diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 650198e8a458..3bd45fee2180 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -2037,7 +2037,13 @@ bool SwTextFormatter::BuildMultiPortion( SwTextFormatInfo &rInf, if (rInf.GetLast()->GetWhichPor() == PortionType::Bookmark) { auto const pBookmark(static_cast<SwBookmarkPortion*>(rInf.GetLast())); - rInf.SetLast(pBookmark->Unchain()); + auto *const pPrevious = pBookmark->FindPrevPortion(rInf.GetRoot()); + assert(!pPrevious || pPrevious->GetNextPortion() == pBookmark); + if (pPrevious) + { + pPrevious->SetNextPortion(nullptr); + } + rInf.SetLast(pPrevious); assert(m_pCurr->GetNextPortion() == nullptr); m_pCurr->SetNextPortion(pBookmark); } diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 47d980183c3c..797725e298f6 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -639,13 +639,4 @@ sal_uInt16 SwControlCharPortion::GetViewWidth( const SwTextSizeInfo& rInf ) cons return mnViewWidth; } -SwLinePortion * SwBookmarkPortion::Unchain() -{ - assert(!m_pPrevious || m_pPrevious->GetNextPortion() == this); - m_pPrevious->SetNextPortion(nullptr); - auto const pTmp(m_pPrevious); - m_pPrevious = nullptr; - return pTmp; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/porrst.hxx b/sw/source/core/text/porrst.hxx index dcb2cfcae7e9..0619c6babe16 100644 --- a/sw/source/core/text/porrst.hxx +++ b/sw/source/core/text/porrst.hxx @@ -156,13 +156,9 @@ public: /// SwControlCharPortion these do not have a character in the text. class SwBookmarkPortion : public SwControlCharPortion { -private: - SwLinePortion * m_pPrevious; - public: - explicit SwBookmarkPortion(SwLinePortion *const pPrevious, sal_Unicode const cChar) + explicit SwBookmarkPortion(sal_Unicode const cChar) : SwControlCharPortion(cChar) - , m_pPrevious(pPrevious) { SetWhichPor(PortionType::Bookmark); SetLen(TextFrameIndex(0)); @@ -171,7 +167,6 @@ public: virtual bool DoPaint(SwTextPaintInfo const& rInf, OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const override; virtual SwLinePortion * Compress() override { return this; } - SwLinePortion * Unchain(); }; #endif |