summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2021-02-08 20:21:12 +0100
committerBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2021-02-08 23:05:39 +0100
commitdc1b416c684c4e2525978e48252d55d78adcfca8 (patch)
treeaddc4f3a1d2bac2e893616dca4399bc25ec71906
parent07d166a81c4287862180bba33cd6259262260ef1 (diff)
Remove SwModify::SetInDocDTOR ...
... its only used once in SwTOXType and has no place in SwModify, which is the base of ~everything in Writer still. Change-Id: I07007f08723f8db2dd09bb7c07cb0ebfc2a6506a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110594 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
-rw-r--r--sw/inc/calbck.hxx1
-rw-r--r--sw/inc/hints.hxx4
-rw-r--r--sw/inc/tox.hxx23
-rw-r--r--sw/source/core/attr/calbck.cxx11
-rw-r--r--sw/source/core/doc/docnew.cxx13
5 files changed, 22 insertions, 30 deletions
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 32b0d35b4c1d..0cd8efbee0ed 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -201,7 +201,6 @@ public:
void LockModify() { m_bModifyLocked = true; }
void UnlockModify() { m_bModifyLocked = false; }
- void SetInDocDTOR();
bool IsModifyLocked() const { return m_bModifyLocked; }
void CheckCaching( const sal_uInt16 nWhich );
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index 25fed4c87783..e83d42251882 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -166,6 +166,10 @@ public:
const SwTableBox& m_rTableBox;
MoveTableBoxHint(const SwFrameFormat& rNewFormat, const SwTableBox& rTableBox): m_rNewFormat(rNewFormat), m_rTableBox(rTableBox) {};
};
+
+class DocumentDyingHint final : public SfxHint
+{
+};
}
class SwUpdateAttr final : public SwMsgPoolItem
diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx
index c7bcaacf036a..f1b496091246 100644
--- a/sw/inc/tox.hxx
+++ b/sw/inc/tox.hxx
@@ -19,20 +19,20 @@
#ifndef INCLUDED_SW_INC_TOX_HXX
#define INCLUDED_SW_INC_TOX_HXX
-#include <cppuhelper/weakref.hxx>
-#include <sal/log.hxx>
+#include <vector>
+#include <cppuhelper/weakref.hxx>
+#include <editeng/svxenum.hxx>
#include <i18nlangtag/lang.h>
-#include <svl/poolitem.hxx>
+#include <o3tl/typed_flags_set.hxx>
+#include <sal/log.hxx>
#include <svl/listener.hxx>
+#include <svl/poolitem.hxx>
-#include <editeng/svxenum.hxx>
+#include "calbck.hxx"
+#include "hints.hxx"
#include "swtypes.hxx"
#include "toxe.hxx"
-#include "calbck.hxx"
-#include <o3tl/typed_flags_set.hxx>
-
-#include <vector>
namespace com::sun::star {
namespace text { class XDocumentIndexMark; }
@@ -467,6 +467,13 @@ public:
SwTOXBase( const SwTOXBase& rCopy, SwDoc* pDoc = nullptr );
virtual ~SwTOXBase() override;
+ virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override
+ {
+ if(dynamic_cast<const sw::DocumentDyingHint*>(&rHint))
+ GetRegisteredIn()->Remove(this);
+ else
+ SwClient::SwClientNotify(rMod, rHint);
+ }
// a kind of CopyCtor - check if the TOXBase is at TOXType of the doc.
// If not, so create it and copy all other used things.
void CopyTOXBase( SwDoc*, const SwTOXBase& );
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 0efc4ada197e..ae840edff48e 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -138,17 +138,6 @@ void SwClient::EndListeningAll()
m_pRegisteredIn->Remove(this);
}
-void SwModify::SetInDocDTOR()
-{
- // If the document gets destroyed anyway, just tell clients to
- // forget me so that they don't try to get removed from my list
- // later when they also get destroyed
- SwIterator<SwClient,SwModify> aIter(*this);
- for(SwClient* pClient = aIter.First(); pClient; pClient = aIter.Next())
- pClient->m_pRegisteredIn = nullptr;
- m_pWriterListeners = nullptr;
-}
-
SwModify::~SwModify()
{
DBG_TESTSOLARMUTEX();
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 575980cac40c..9c789deb66b7 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -466,16 +466,9 @@ SwDoc::~SwDoc()
delete pTmp;
}
- // Old - deletion without a Flag is expensive, because we send a Modify
- // aTOXTypes.DeleteAndDestroy( 0, aTOXTypes.Count() );
- {
- for( auto n = mpTOXTypes->size(); n; )
- {
- (*mpTOXTypes)[ --n ]->SetInDocDTOR();
- (*mpTOXTypes)[ n ].reset();
- }
- mpTOXTypes->clear();
- }
+ for(auto& pType : *mpTOXTypes)
+ pType->CallSwClientNotify(sw::DocumentDyingHint());
+ mpTOXTypes->clear();
mpDefTOXBases.reset();
// Any of the FrameFormats can still have indices registered.