Kaydet (Commit) 1a044b25 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen Kaydeden (comit) Björn Michaelsen

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/34985Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
üst fe73eff3
...@@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_use_libraries,editeng_core, \ ...@@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_use_libraries,editeng_core, \
salhelper \ salhelper \
sax \ sax \
sot \ sot \
sfx \
svl \ svl \
svt \ svt \
test \ test \
......
...@@ -136,6 +136,7 @@ $(eval $(call gb_Library_use_libraries,editeng,\ ...@@ -136,6 +136,7 @@ $(eval $(call gb_Library_use_libraries,editeng,\
vcl \ vcl \
svl \ svl \
sot \ sot \
sfx \
utl \ utl \
tl \ tl \
comphelper \ comphelper \
......
...@@ -1031,6 +1031,7 @@ public: ...@@ -1031,6 +1031,7 @@ public:
mark (apostrophe) or not (default is on) */ mark (apostrophe) or not (default is on) */
void SetReplaceLeadingSingleQuotationMark( bool bReplace ) { mbReplaceLeadingSingleQuotationMark = bReplace; } void SetReplaceLeadingSingleQuotationMark( bool bReplace ) { mbReplaceLeadingSingleQuotationMark = bReplace; }
bool IsReplaceLeadingSingleQuotationMark() const { return mbReplaceLeadingSingleQuotationMark; } bool IsReplaceLeadingSingleQuotationMark() const { return mbReplaceLeadingSingleQuotationMark; }
void Dispose();
}; };
inline EPaM ImpEditEngine::CreateEPaM( const EditPaM& rPaM ) inline EPaM ImpEditEngine::CreateEPaM( const EditPaM& rPaM )
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <eeobj.hxx> #include <eeobj.hxx>
#include <editeng/txtrange.hxx> #include <editeng/txtrange.hxx>
#include <svl/urlbmk.hxx> #include <svl/urlbmk.hxx>
#include <sfx2/app.hxx>
#include <svtools/colorcfg.hxx> #include <svtools/colorcfg.hxx>
#include <svl/ctloptions.hxx> #include <svl/ctloptions.hxx>
#include <editeng/acorrcfg.hxx> #include <editeng/acorrcfg.hxx>
...@@ -163,6 +164,17 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) : ...@@ -163,6 +164,17 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) :
bCallParaInsertedOrDeleted = true; bCallParaInsertedOrDeleted = true;
aEditDoc.SetModifyHdl( LINK( this, ImpEditEngine, DocModified ) ); 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() ImpEditEngine::~ImpEditEngine()
...@@ -177,8 +189,7 @@ ImpEditEngine::~ImpEditEngine() ...@@ -177,8 +189,7 @@ ImpEditEngine::~ImpEditEngine()
bDowning = true; bDowning = true;
SetUpdateMode( false ); SetUpdateMode( false );
mpOwnDev.disposeAndClear(); Dispose();
pVirtDev.disposeAndClear();
delete pEmptyItemSet; delete pEmptyItemSet;
delete pUndoManager; delete pUndoManager;
delete pTextRanger; delete pTextRanger;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <editdbg.hxx> #include <editdbg.hxx>
#include <svl/hint.hxx> #include <svl/hint.hxx>
#include <editeng/lrspitem.hxx> #include <editeng/lrspitem.hxx>
#include <sfx2/app.hxx>
void ImpEditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool ) void ImpEditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool )
{ {
...@@ -173,6 +174,8 @@ void ImpEditEngine::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) ...@@ -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 ) EditUndoSetAttribs* ImpEditEngine::CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment