editeng/CppunitTest_editeng_core.mk | 1 + editeng/Library_editeng.mk | 1 + editeng/source/editeng/impedit.hxx | 1 + editeng/source/editeng/impedit2.cxx | 15 +++++++++++++-- editeng/source/editeng/impedit5.cxx | 3 +++ 5 files changed, 19 insertions(+), 2 deletions(-)
New commits: commit 1a044b25c279236d9f67847ec6ad426d8c5aac13 Author: Bjoern Michaelsen <[email protected]> Date: Thu Mar 9 00:35:42 2017 +0100 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 <[email protected]> Tested-by: Björn Michaelsen <[email protected]> diff --git a/editeng/CppunitTest_editeng_core.mk b/editeng/CppunitTest_editeng_core.mk index 00d2b80..c7a9610 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 c6c2fa0..88ba855 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 5a6ba26..106221f 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 1341ec7..3338111 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 edf94a0..fca0358 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 )
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
