sw/inc/init.hxx                   |    2 +-
 sw/inc/swatrset.hxx               |    3 ++-
 sw/inc/swmodule.hxx               |    5 +++++
 sw/source/core/attr/hints.cxx     |    5 +++--
 sw/source/core/attr/swatrset.cxx  |    4 ++--
 sw/source/core/bastyp/init.cxx    |    8 ++------
 sw/source/core/doc/docnew.cxx     |    3 ++-
 sw/source/uibase/app/swdll.cxx    |    3 ++-
 sw/source/uibase/app/swmodule.cxx |   13 +++++++++++--
 9 files changed, 30 insertions(+), 16 deletions(-)

New commits:
commit 42a61cc6eb1332ed048cbab2a2e0cb667a6a8193
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Tue Aug 26 10:14:28 2025 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Aug 26 13:25:45 2025 +0200

    move ItemInfoPackageSwAttributes to SwModule
    
    for the edgecase that DeInitVCL isn't called during lokit teardown,
    so in a dbgutil version the SolarMutex assert fires when the
    g_aItemInfoPackageSwAttributes is destroyed on exit because DeInitVCL
    unsets the pDbgTestSolarMutex pointer
    
    In this scenario the SwDLL is still destoyed at a sensible time due
    to the unique_disposing_solar_mutex_reset_ptr SwDLLInstance. So move
    the ItemInfoPackageSwAttributes to someplace which SwDLLInstance
    shutdown can clear it, SwModule seems like the sensible place as
    its the owner of the primorial SwAttrPool, so make SwModule
    own the ItemInfoPackageSwAttributes
    
    Change-Id: I0f075ee5b488df5a8011648457779eddbbd95c37
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190207
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/inc/init.hxx b/sw/inc/init.hxx
index 5c6e358c0a01..11c9936b14b6 100644
--- a/sw/inc/init.hxx
+++ b/sw/inc/init.hxx
@@ -32,7 +32,7 @@ class ItemInfoPackage;
 
 void InitCore();   // bastyp/init.cxx
 void FinitCore();
-ItemInfoPackage& getItemInfoPackageSwAttributes();
+std::unique_ptr<ItemInfoPackage> createItemInfoPackageSwAttributes();
 
 namespace sw {
 
diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx
index 78f3d42f9c4a..8cec8f9ee298 100644
--- a/sw/inc/swatrset.hxx
+++ b/sw/inc/swatrset.hxx
@@ -27,6 +27,7 @@
 class SwDoc;
 class OutputDevice;
 class IDocumentSettingAccess;
+class ItemInfoPackage;
 class SvxPostureItem;
 class SvxWeightItem;
 class SvxShadowedItem;
@@ -149,7 +150,7 @@ private:
     SwDoc* m_pDoc;
 
 public:
-    SwAttrPool( SwDoc* pDoc );
+    SwAttrPool(ItemInfoPackage& rInfoPackage, SwDoc* pDoc);
 private:
     virtual ~SwAttrPool() override;
 public:
diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx
index 78be7d1a45f8..a80df0fed62e 100644
--- a/sw/inc/swmodule.hxx
+++ b/sw/inc/swmodule.hxx
@@ -36,6 +36,7 @@
 #include "fldupde.hxx"
 
 class Color;
+class ItemInfoPackage;
 class SfxItemSet;
 class SfxRequest;
 class SfxErrorHandler;
@@ -97,6 +98,8 @@ class SAL_DLLPUBLIC_RTTI SwModule final : public SfxModule, 
public SfxListener,
 
     std::unique_ptr<SwTableAutoFormatTable> m_xTableAutoFormatTable;
 
+    std::unique_ptr<ItemInfoPackage> m_xItemInfoPackageSwAttributes;
+
     rtl::Reference<SwAttrPool> m_pAttrPool;
 
     // Current view is held here in order to avoid one's being forced
@@ -242,6 +245,8 @@ public:
     // Delete pool before it is too late.
     void    RemoveAttrPool();
 
+    ItemInfoPackage& getItemInfoPackageSwAttributes();
+
     // Invalidates online spell-wrong-lists if necessary.
     static void  CheckSpellChanges( bool bOnlineSpelling,
                     bool bIsSpellWrongAgain, bool bIsSpellAllAgain, bool 
bSmartTags );
diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx
index bd3a14bf5c06..05ebdc077694 100644
--- a/sw/source/core/attr/hints.cxx
+++ b/sw/source/core/attr/hints.cxx
@@ -21,6 +21,7 @@
 #include <hintids.hxx>
 #include <hints.hxx>
 #include <ndtxt.hxx>
+#include <swmodule.hxx>
 #include <swtypes.hxx>
 #include <init.hxx>
 #include <svl/languageoptions.hxx>
@@ -138,11 +139,11 @@ const SfxPoolItem* GetDfltAttr(sal_uInt16 nWhich)
 {
 #ifdef DBG_UTIL
     OSL_ASSERT(nWhich < POOLATTR_END && nWhich >= POOLATTR_BEGIN);
-    const SfxPoolItem* 
pRetval(getItemInfoPackageSwAttributes().getExistingItemInfo(nWhich - 
POOLATTR_BEGIN).getItem());
+    const SfxPoolItem* 
pRetval(SwModule::get()->getItemInfoPackageSwAttributes().getExistingItemInfo(nWhich
 - POOLATTR_BEGIN).getItem());
     OSL_ENSURE(pRetval, "GetDfltFormatAttr(): Dflt == 0");
     return pRetval;
 #else
-    return getItemInfoPackageSwAttributes().getExistingItemInfo(nWhich - 
POOLATTR_BEGIN).getItem();
+    return 
SwModule::get()->getItemInfoPackageSwAttributes().getExistingItemInfo(nWhich - 
POOLATTR_BEGIN).getItem();
 #endif
 }
 
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index 1c940aee9089..83b7c06e0ccc 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -45,11 +45,11 @@
 
 
 
-SwAttrPool::SwAttrPool(SwDoc* pD)
+SwAttrPool::SwAttrPool(ItemInfoPackage& rInfoPackage, SwDoc* pD)
 : SfxItemPool(u"SWG"_ustr)
 , m_pDoc(pD)
 {
-    registerItemInfoPackage(getItemInfoPackageSwAttributes());
+    registerItemInfoPackage(rInfoPackage);
 
     // create SfxItemPool and EditEngine pool and add these in a chain. These
     // belong us and will be removed/destroyed in 
removeAndDeleteSecondaryPools() used from
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index da24bbaf4d5e..4a06f438f6ac 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -270,7 +270,7 @@ SwTOXMark* createSwTOXMarkForItemInfoPackage()
     return new SwTOXMark();
 }
 
-ItemInfoPackage& getItemInfoPackageSwAttributes()
+std::unique_ptr<ItemInfoPackage> createItemInfoPackageSwAttributes()
 {
     class ItemInfoPackageSwAttributes : public ItemInfoPackage
     {
@@ -494,11 +494,7 @@ ItemInfoPackage& getItemInfoPackageSwAttributes()
         }
     };
 
-
-    static std::unique_ptr<ItemInfoPackageSwAttributes> 
g_aItemInfoPackageSwAttributes;
-    if (!g_aItemInfoPackageSwAttributes)
-        g_aItemInfoPackageSwAttributes.reset(new ItemInfoPackageSwAttributes);
-    return *g_aItemInfoPackageSwAttributes;
+    return std::make_unique<ItemInfoPackageSwAttributes>();
 }
 
 std::vector<SvGlobalName> *pGlobalOLEExcludeList = nullptr;
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index f3b9e768557a..82306f6f787e 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -99,6 +99,7 @@
 #include <DocumentStylePoolManager.hxx>
 #include <DocumentExternalDataManager.hxx>
 #include <wrtsh.hxx>
+#include <swmodule.hxx>
 #include <unocrsr.hxx>
 #include <fmthdft.hxx>
 #include <frameformats.hxx>
@@ -207,7 +208,7 @@ static void lcl_DelFormatIndices( SwFormat const * pFormat )
  */
 SwDoc::SwDoc()
     : m_pNodes(new SwNodes(*this)),
-    mpAttrPool(new SwAttrPool(this)),
+    mpAttrPool(new 
SwAttrPool(SwModule::get()->getItemInfoPackageSwAttributes(), this)),
     maOLEModifiedIdle( "sw::SwDoc maOLEModifiedIdle" ),
     mpMarkManager(new ::sw::mark::MarkManager(*this)),
     m_pMetaFieldManager(new ::sw::MetaFieldManager()),
diff --git a/sw/source/uibase/app/swdll.cxx b/sw/source/uibase/app/swdll.cxx
index 274b0e50c319..1f7cb7ab800d 100644
--- a/sw/source/uibase/app/swdll.cxx
+++ b/sw/source/uibase/app/swdll.cxx
@@ -155,11 +155,12 @@ SwDLL::~SwDLL() COVERITY_NOEXCEPT_FALSE
         m_pAutoCorrCfg->SetAutoCorrect(nullptr); // delete SwAutoCorrect 
before exit handlers
     }
 
+    m_pFilters.reset();
+
     // Pool has to be deleted before statics are
     SwModule::get()->RemoveAttrPool();
 
     ::FinitUI();
-    m_pFilters.reset();
     ::FinitCore();
     // sign out object-Factory
     SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, 
SwObjectFactory, MakeObject ));
diff --git a/sw/source/uibase/app/swmodule.cxx 
b/sw/source/uibase/app/swmodule.cxx
index 130d9ba9e78c..c7b8029abb48 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -73,6 +73,7 @@
 #include <wtabsh.hxx>
 #include <navipi.hxx>
 #include <QuickFindPanel.hxx>
+#include <init.hxx>
 #include <inputwin.hxx>
 #include <usrpref.hxx>
 #include <uinums.hxx>
@@ -342,15 +343,23 @@ void SwDLL::RegisterControls()
 // Load Module (only dummy for linking of the DLL)
 void    SwModule::InitAttrPool()
 {
-    OSL_ENSURE(!m_pAttrPool, "Pool already exists!");
-    m_pAttrPool = new SwAttrPool(nullptr);
+    OSL_ENSURE(!m_pAttrPool && !m_xItemInfoPackageSwAttributes, "Pool already 
exists!");
+    m_xItemInfoPackageSwAttributes = createItemInfoPackageSwAttributes();
+    m_pAttrPool = new SwAttrPool(*m_xItemInfoPackageSwAttributes, nullptr);
     SetPool(m_pAttrPool.get());
 }
 
+ItemInfoPackage& SwModule::getItemInfoPackageSwAttributes()
+{
+    assert(m_xItemInfoPackageSwAttributes && "InitAttrPool should have been 
called before this");
+    return *m_xItemInfoPackageSwAttributes;
+}
+
 void    SwModule::RemoveAttrPool()
 {
     SetPool(nullptr);
     m_pAttrPool.clear();
+    m_xItemInfoPackageSwAttributes.reset();
 }
 
 std::optional<SfxStyleFamilies> SwModule::CreateStyleFamilies()

Reply via email to