[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/qa sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 3 12:40:05 UTC 2020


 sw/qa/extras/layout/data/abi11870-2.odt |binary
 sw/qa/extras/layout/layout.cxx          |    6 ++++++
 sw/source/core/text/itrform2.cxx        |    2 +-
 sw/source/core/text/pormulti.cxx        |    8 +++++++-
 sw/source/core/text/porrst.cxx          |    9 ---------
 sw/source/core/text/porrst.hxx          |    7 +------
 6 files changed, 15 insertions(+), 17 deletions(-)

New commits:
commit deee67c566811189ee66d5766d0c9fc644a0120b
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Jun 2 18:16:15 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Wed Jun 3 14:39:31 2020 +0200

    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 at redhat.com>
    (cherry picked from commit f68749054f36f070310e70e2dbf0a11c496539c0)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95415
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/qa/extras/layout/data/abi11870-2.odt b/sw/qa/extras/layout/data/abi11870-2.odt
new file mode 100644
index 000000000000..b02bb85646aa
Binary files /dev/null and b/sw/qa/extras/layout/data/abi11870-2.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index adac583c8ed2..b896df2e03d4 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3403,6 +3403,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 9e1abfa1bec8..17900f1a17e0 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -1190,7 +1190,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 f72e120848f6..2154eba1df73 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -2039,7 +2039,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 32b1e0b389c0..69183bc58557 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -630,13 +630,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 3d4c54c7ecd8..7c716be8dba5 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


More information about the Libreoffice-commits mailing list