sc/inc/document.hxx              |    1 -
 sc/source/core/data/docpool.cxx  |    1 +
 sc/source/core/data/documen2.cxx |    2 +-
 sc/source/core/data/documen9.cxx |   18 ------------------
 4 files changed, 2 insertions(+), 20 deletions(-)

New commits:
commit ba58d80a1a9c30e58b20184135e81cc1851bdd75
Author:     Maxim Monastirsky <momonas...@gmail.com>
AuthorDate: Sun Mar 19 00:16:00 2023 +0200
Commit:     Maxim Monastirsky <momonas...@gmail.com>
CommitDate: Sun Mar 19 17:40:26 2023 +0000

    sc drawstyles: Delay the destruction of SdrItemPool
    
    Nowadays SfxItemPool_Impl::mpSecondary is ref counted, so
    there is no fear in destroying the draw layer before the doc
    pool.
    
    This kind of change is needed for drawing styles, as their
    item set references the SdrItemPool with a raw pointer, but
    they are destroyed as part of the styles pool, much later
    than the draw layer.
    
    Change-Id: I169bbacfbdbec2121217b13293b6f495898fe2e4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149090
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonas...@gmail.com>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 137b786e8c8b..9c6e376acca5 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2673,7 +2673,6 @@ private:
     void    ImplCreateOptions(); // Suggestion: switch to on-demand?
     void    ImplDeleteOptions();
 
-    void    DeleteDrawLayer();
     SC_DLLPUBLIC bool   DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool 
bSetVer ) const;
 
     void    UpdateDrawPrinter();
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index e0a07582e453..47c485e4f139 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -327,6 +327,7 @@ ScDocumentPool::ScDocumentPool()
 ScDocumentPool::~ScDocumentPool()
 {
     Delete();
+    SetSecondaryPool(nullptr);
 
     for ( sal_uInt16 i=0; i < ATTR_ENDINDEX-ATTR_STARTINDEX+1; i++ )
     {
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index a7ea162177a9..fa979a953cb8 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -386,7 +386,7 @@ ScDocument::~ScDocument()
     pDBCollection.reset();
     pSelectionAttr.reset();
     apTemporaryChartLock.reset();
-    DeleteDrawLayer();
+    mpDrawLayer.reset();
     mpPrinter.disposeAndClear();
     ImplDeleteOptions();
     pConsolidateDlgData.reset();
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index b471a9a0f0f6..e6a6501c46e4 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -226,24 +226,6 @@ IMPL_LINK( ScDocument, GetUserDefinedColor, sal_uInt16, 
nColorIndex, Color* )
     return 
const_cast<Color*>(&(xColorList->GetColor(nColorIndex)->GetColor()));
 }
 
-void ScDocument::DeleteDrawLayer()
-{
-    ScMutationGuard aGuard(*this, ScMutationGuardFlags::CORE);
-
-    // remove DrawingLayer's SfxItemPool from Calc's SfxItemPool where
-    // it is registered as secondary pool
-    if (mxPoolHelper.is() && !IsClipOrUndo()) //Using IsClipOrUndo as a proxy 
for SharePooledResources called
-    {
-        ScDocumentPool* pLocalPool = mxPoolHelper->GetDocPool();
-
-        if(pLocalPool && pLocalPool->GetSecondaryPool())
-        {
-            pLocalPool->SetSecondaryPool(nullptr);
-        }
-    }
-    mpDrawLayer.reset();
-}
-
 bool ScDocument::DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer 
) const
 {
     return mpDrawLayer->GetPrintArea( rRange, bSetHor, bSetVer );

Reply via email to