From 6b50f11fafad9b934bef24259ebf90fbfb1d0a30 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Mon, 25 Aug 2014 22:15:09 +0200 Subject: fix nasty memory leak on shutdown This makes the output of Lsan so much more useful. Change-Id: I6c7624d4f6f767454c125c00ce037f5d2ec3cd61 --- vcl/inc/idlemgr.hxx | 1 + vcl/source/app/idlemgr.cxx | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/idlemgr.hxx b/vcl/inc/idlemgr.hxx index 02fc85ec0985..4e0a6396b8cf 100644 --- a/vcl/inc/idlemgr.hxx +++ b/vcl/inc/idlemgr.hxx @@ -31,6 +31,7 @@ class ImplIdleMgr private: ImplIdleList* mpIdleList; AutoTimer maTimer; + bool mbInDestruction; public: ImplIdleMgr(); diff --git a/vcl/source/app/idlemgr.cxx b/vcl/source/app/idlemgr.cxx index cd41d1260caa..fbbd14159ec1 100644 --- a/vcl/source/app/idlemgr.cxx +++ b/vcl/source/app/idlemgr.cxx @@ -30,7 +30,8 @@ struct ImplIdleData #define IMPL_IDLETIMEOUT 350 -ImplIdleMgr::ImplIdleMgr() +ImplIdleMgr::ImplIdleMgr(): + mbInDestruction(false) { mpIdleList = new ImplIdleList(); @@ -40,9 +41,12 @@ ImplIdleMgr::ImplIdleMgr() ImplIdleMgr::~ImplIdleMgr() { + mbInDestruction = true; // Liste loeschen for ( size_t i = 0, n = mpIdleList->size(); i < n; ++i ) { - delete (*mpIdleList)[ i ]; + ImplIdleData* pIdleData = (*mpIdleList)[ i ]; + pIdleData->maIdleHdl.Call( GetpApp() ); + delete pIdleData; } mpIdleList->clear(); delete mpIdleList; @@ -84,6 +88,9 @@ bool ImplIdleMgr::InsertIdleHdl( const Link& rLink, sal_uInt16 nPriority ) void ImplIdleMgr::RemoveIdleHdl( const Link& rLink ) { + if (mbInDestruction) + return; + for ( ImplIdleList::iterator it = mpIdleList->begin(); it != mpIdleList->end(); ++it ) { if ( (*it)->maIdleHdl == rLink ) { delete *it; -- cgit