diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2017-03-09 00:35:42 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@canonical.com> | 2017-03-10 12:59:26 +0000 |
commit | 1a044b25c279236d9f67847ec6ad426d8c5aac13 (patch) | |
tree | 976653fc4df74d4a5b36d469d737e019ac0a1af2 /editeng | |
parent | fe73eff36718b6d99d0cf92d750c457872cc4dcc (diff) |
tdf#99352: dispose EditEngines when SfxApp dies
In an ideal world, by the time we reach DeInitVCL() there should be
neither non-null VclPtr nor EditEngine instances around. This fixes the
former for those VclPtrs owned by EditEngines, by disposing them when
SfxApplication is dying. The goal is -- for now -- to not have any
non-null VclPtrs around by DeInitVCL(), so we can e.g. assert() on that
to pick up regressions.
Should we one day have all EditEngines accounted for with proper smart
pointers that get torn down before DeInitVCL(), the Dispose() introduced
here might be removed again.
Change-Id: I47b17f7fd31fce2ac5fd6f6b146d356d7d07e677
Reviewed-on: https://gerrit.libreoffice.org/34985
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/CppunitTest_editeng_core.mk | 1 | ||||
-rw-r--r-- | editeng/Library_editeng.mk | 1 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 1 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 15 | ||||
-rw-r--r-- | editeng/source/editeng/impedit5.cxx | 3 |
5 files changed, 19 insertions, 2 deletions
diff --git a/editeng/CppunitTest_editeng_core.mk b/editeng/CppunitTest_editeng_core.mk index 00d2b80527aa..c7a9610e55a9 100644 --- a/editeng/CppunitTest_editeng_core.mk +++ b/editeng/CppunitTest_editeng_core.mk @@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_use_libraries,editeng_core, \ salhelper \ sax \ sot \ + sfx \ svl \ svt \ test \ diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk index c6c2fa06b666..88ba8557bb50 100644 --- a/editeng/Library_editeng.mk +++ b/editeng/Library_editeng.mk @@ -136,6 +136,7 @@ $(eval $(call gb_Library_use_libraries,editeng,\ vcl \ svl \ sot \ + sfx \ utl \ tl \ comphelper \ diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 5a6ba262cd68..106221f3b195 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -1031,6 +1031,7 @@ public: mark (apostrophe) or not (default is on) */ void SetReplaceLeadingSingleQuotationMark( bool bReplace ) { mbReplaceLeadingSingleQuotationMark = bReplace; } bool IsReplaceLeadingSingleQuotationMark() const { return mbReplaceLeadingSingleQuotationMark; } + void Dispose(); }; inline EPaM ImpEditEngine::CreateEPaM( const EditPaM& rPaM ) diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 1341ec7b031f..3338111fc206 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -35,6 +35,7 @@ #include <eeobj.hxx> #include <editeng/txtrange.hxx> #include <svl/urlbmk.hxx> +#include <sfx2/app.hxx> #include <svtools/colorcfg.hxx> #include <svl/ctloptions.hxx> #include <editeng/acorrcfg.hxx> @@ -163,6 +164,17 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) : bCallParaInsertedOrDeleted = true; aEditDoc.SetModifyHdl( LINK( this, ImpEditEngine, DocModified ) ); + StartListening(*SfxGetpApp()); +} + +void ImpEditEngine::Dispose() +{ + SolarMutexGuard g; + auto pApp = SfxApplication::Get(); + if(pApp) + EndListening(*pApp); + pVirtDev.disposeAndClear(); + mpOwnDev.disposeAndClear(); } ImpEditEngine::~ImpEditEngine() @@ -177,8 +189,7 @@ ImpEditEngine::~ImpEditEngine() bDowning = true; SetUpdateMode( false ); - mpOwnDev.disposeAndClear(); - pVirtDev.disposeAndClear(); + Dispose(); delete pEmptyItemSet; delete pUndoManager; delete pTextRanger; diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index edf94a0efd39..fca0358ae757 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -26,6 +26,7 @@ #include <editdbg.hxx> #include <svl/hint.hxx> #include <editeng/lrspitem.hxx> +#include <sfx2/app.hxx> void ImpEditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool ) { @@ -173,6 +174,8 @@ void ImpEditEngine::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) } } } + if(dynamic_cast<const SfxApplication*>(&rBC) != nullptr && rHint.GetId() == SfxHintId::Dying) + Dispose(); } EditUndoSetAttribs* ImpEditEngine::CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet ) |