Kaydet (Commit) 6b50f11f authored tarafından Markus Mohrhard's avatar Markus Mohrhard

fix nasty memory leak on shutdown

This makes the output of Lsan so much more useful.

Change-Id: I6c7624d4f6f767454c125c00ce037f5d2ec3cd61
üst f6c0803e
...@@ -31,6 +31,7 @@ class ImplIdleMgr ...@@ -31,6 +31,7 @@ class ImplIdleMgr
private: private:
ImplIdleList* mpIdleList; ImplIdleList* mpIdleList;
AutoTimer maTimer; AutoTimer maTimer;
bool mbInDestruction;
public: public:
ImplIdleMgr(); ImplIdleMgr();
......
...@@ -30,7 +30,8 @@ struct ImplIdleData ...@@ -30,7 +30,8 @@ struct ImplIdleData
#define IMPL_IDLETIMEOUT 350 #define IMPL_IDLETIMEOUT 350
ImplIdleMgr::ImplIdleMgr() ImplIdleMgr::ImplIdleMgr():
mbInDestruction(false)
{ {
mpIdleList = new ImplIdleList(); mpIdleList = new ImplIdleList();
...@@ -40,9 +41,12 @@ ImplIdleMgr::ImplIdleMgr() ...@@ -40,9 +41,12 @@ ImplIdleMgr::ImplIdleMgr()
ImplIdleMgr::~ImplIdleMgr() ImplIdleMgr::~ImplIdleMgr()
{ {
mbInDestruction = true;
// Liste loeschen // Liste loeschen
for ( size_t i = 0, n = mpIdleList->size(); i < n; ++i ) { 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(); mpIdleList->clear();
delete mpIdleList; delete mpIdleList;
...@@ -84,6 +88,9 @@ bool ImplIdleMgr::InsertIdleHdl( const Link& rLink, sal_uInt16 nPriority ) ...@@ -84,6 +88,9 @@ bool ImplIdleMgr::InsertIdleHdl( const Link& rLink, sal_uInt16 nPriority )
void ImplIdleMgr::RemoveIdleHdl( const Link& rLink ) void ImplIdleMgr::RemoveIdleHdl( const Link& rLink )
{ {
if (mbInDestruction)
return;
for ( ImplIdleList::iterator it = mpIdleList->begin(); it != mpIdleList->end(); ++it ) { for ( ImplIdleList::iterator it = mpIdleList->begin(); it != mpIdleList->end(); ++it ) {
if ( (*it)->maIdleHdl == rLink ) { if ( (*it)->maIdleHdl == rLink ) {
delete *it; delete *it;
......
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