sd/inc/drawdoc.hxx          |    2 ++
 sd/source/core/drawdoc.cxx  |    2 ++
 sd/source/core/drawdoc2.cxx |    6 ++++--
 3 files changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 70c81a9a3d5e10f3de8a1a7d4903670626bcd0ec
Author:     Mohit Marathe <[email protected]>
AuthorDate: Tue Dec 16 18:56:01 2025 +0530
Commit:     Mohit Marathe <[email protected]>
CommitDate: Wed Dec 17 13:12:40 2025 +0100

    sd: allow dtor of SdDrawDocument to remove pages unconditionally
    
    Fixes the exception:
    0 sal::backtrace_get(unsigned int) at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/sal/osl/unx/backtraceapi.cxx:42
    1 (anonymous namespace)::printStack(int) at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/sal/osl/unx/signal.cxx:289
    2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/sal/osl/unx/signal.cxx:330
    3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/sal/osl/unx/signal.cxx:427
    4 __restore_rt in /lib64/libpthread.so.0
    5 __GI_raise at :?
    6 __GI_abort at :?
    7 /lib64/libstdc++.so.6(+0x91f97) [0x7f4c69c91f97]
    8 std::__debug::vector<SdrPageObj*, std::allocator<SdrPageObj*> 
>::operator[](unsigned long) at 
/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/debug/vector:442
    9 SdDrawDocument::connectPagePreviews() at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/sd/source/core/drawdoc2.cxx:1794
    10 SdDrawDocument::updatePagePreviewsGrid(SdPage*) at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/sd/source/core/drawdoc2.cxx:1770
    11 SdDrawDocument::RemovePage(unsigned short) at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/sd/source/core/drawdoc2.cxx:540
    12 SdrModel::DeletePage(unsigned short) at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/svx/source/svdraw/svdmodel.cxx:1224
    13 SdDrawDocument::DeletePage(unsigned short) at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/sd/source/core/drawdoc2.cxx:494
    14 SdrModel::ClearModel(bool) at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/svx/source/svdraw/svdmodel.cxx:608
    15 ~SdDrawDocument at 
/home/collabora/jenkins/workspace/gerrit_linux_co-25.04_clang_dbgutil/sd/source/core/drawdoc.cxx:380
    
    Signed-off-by: Mohit Marathe <[email protected]>
    Change-Id: Ie878a6a14d94a43bef9f53f2795d8cf4b768b5a2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195717
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index d3002d37ea3c..cc21ae619f97 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -390,6 +390,8 @@ private:
 
     bool                mbNewOrLoadCompleted;
 
+    bool                mbDestroying = false;
+
     bool                mbOnlineSpell;
     bool                mbSummationOfParagraphs;
     sal_uInt16          mnStartWithPresentation; ///< 1-based starting slide# 
when presenting via command line parameter --show
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index c569cd4d2f69..c095d1a48bcc 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -359,6 +359,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, 
SfxObjectShell* pDrDocSh)
 // Destructor
 SdDrawDocument::~SdDrawDocument()
 {
+    mbDestroying = true;
     s_pLast = nullptr;
 
     Broadcast(SdrHint(SdrHintKind::ModelCleared));
@@ -396,6 +397,7 @@ SdDrawDocument::~SdDrawDocument()
     mpOutliner.reset();
     mpInternalOutliner.reset();
     moCharClass.reset();
+    mbDestroying = false;
 }
 
 void SdDrawDocument::adaptSizeAndBorderForAllPages(
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index 2a2f7f7612b6..199816b574ed 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -507,7 +507,7 @@ rtl::Reference<SdrPage> 
SdDrawDocument::RemovePage(sal_uInt16 nPgNum)
 {
     // Do not remove the only non-canvas page
     if (HasCanvasPage() && GetSdPageCount(PageKind::Standard) == 2
-        && nPgNum == 3)
+        && nPgNum == 3 && !mbDestroying)
         return nullptr;
     rtl::Reference<SdrPage> pPage = FmFormModel::RemovePage(nPgNum);
 
@@ -536,8 +536,10 @@ rtl::Reference<SdrPage> 
SdDrawDocument::RemovePage(sal_uInt16 nPgNum)
         SfxLokHelper::notifyDocumentSizeChangedAllViews(pDoc);
     }
 
-    if (HasCanvasPage())
+    if (HasCanvasPage() && !mbDestroying)
+    {
         updatePagePreviewsGrid(pSdPage);
+    }
 
     return pPage;
 }

Reply via email to