sw/qa/uitest/data/tdf163325.odt         |binary
 sw/qa/uitest/writer_tests5/tdf163325.py |   35 ++++++++++++++++++++++++++++++++
 sw/source/core/layout/sectfrm.cxx       |    8 ++++---
 3 files changed, 40 insertions(+), 3 deletions(-)

New commits:
commit e5512ee6e637cd4fb8d0e2f2b469eba339e655c9
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Mon Nov 25 09:17:45 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Dec 10 04:17:43 2024 +0100

    tdf#163325 - Check Lower() frame during ToC preview
    
    Change-Id: Ife0e974d66d5ddbe3c831c64e4da28442e476da4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177234
    Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de>
    Tested-by: Jenkins
    (cherry picked from commit 2145204724049cad1585743c0b980ed2c6561212)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177529
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 2d57e13895703b541b918c0933b7dc5bbe25c300)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177666
    Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/qa/uitest/data/tdf163325.odt b/sw/qa/uitest/data/tdf163325.odt
new file mode 100644
index 000000000000..3d2e6e8673cf
Binary files /dev/null and b/sw/qa/uitest/data/tdf163325.odt differ
diff --git a/sw/qa/uitest/writer_tests5/tdf163325.py 
b/sw/qa/uitest/writer_tests5/tdf163325.py
new file mode 100644
index 000000000000..391859cdb715
--- /dev/null
+++ b/sw/qa/uitest/writer_tests5/tdf163325.py
@@ -0,0 +1,35 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import org.libreoffice.unotest
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_url_for_data_file, get_state_as_dict
+
+class tdf163325(UITestCase):
+
+    def test_tdf163325_toc_preview_crash(self):
+        with self.ui_test.load_file(get_url_for_data_file("tdf163325.odt")):
+            # Open ToC dialog and check index preview
+            with 
self.ui_test.execute_dialog_through_command(".uno:InsertMultiIndex") as 
xTocDialog:
+                xShowExample = xTocDialog.getChild("showexample")
+                xShowExample.executeAction("CLICK", tuple())
+                self.assertEqual(get_state_as_dict(xShowExample)["Selected"], 
"true")
+
+            # Save, reload and update all indexes in the document
+            self.xUITest.executeCommand('.uno:Save')
+            self.xUITest.executeCommand('.uno:Reload')
+            # Without the fix in place, this test would have crashed here
+            self.xUITest.executeCommand(".uno:UpdateAllIndexes")
+
+        with self.ui_test.load_file(get_url_for_data_file("tdf163325.odt")) as 
document:
+            # Check that the index is present
+            xDocumentIndexes = document.DocumentIndexes
+            self.assertEqual(len(xDocumentIndexes), 1)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index 33253dafbe54..803686e7e3d9 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -2755,7 +2755,8 @@ void SwSectionFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         }
 
         InvalidateFramesInSection(Lower());
-        Lower()->HideAndShowObjects(); // recursive
+        if (Lower())
+            Lower()->HideAndShowObjects(); // recursive
         // Check if any page-breaks have been unhidden, create the new pages.
         // Call IsHiddenNow() because a parent section could still hide.
         if (!IsFollow() && IsInDocBody() && !IsInTab() && !IsHiddenNow())
@@ -2784,8 +2785,9 @@ void SwSectionFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
                 pFirstOnPage = pFirstOnPage->GetUpper();
             }
             assert(pFirstOnPage->IsContentFrame() || 
pFirstOnPage->IsTabFrame());
-            SwColumnFrame * pColumn{Lower()->IsColumnFrame()
-                    ? static_cast<SwColumnFrame*>(Lower()) : nullptr};
+            SwColumnFrame* pColumn{ Lower() && Lower()->IsColumnFrame()
+                                        ? static_cast<SwColumnFrame*>(Lower())
+                                        : nullptr };
             auto IterateLower = [&pColumn](SwFrame *const pLowerFrame) -> 
SwFrame*
             {
                 if (pLowerFrame->GetNext())

Reply via email to