From 6dc2a916dfa34137434a17ba7d89d875d17ebbc9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 8 Nov 2005 00:45:46 +0000 Subject: [PATCH] fix memory leak of pending events in wxEvtHandler dtor git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36118 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/event.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 8ee50ea1a7..dd89687033 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -29,6 +29,7 @@ All (GUI): - Added wxBitmapButton::SetHoverBitmap() - Access to titles through Get/SetTitle is available now only for top level windows (wxDialog, wxFrame). +- Fixed memory leak of pending events in wxEvtHandler wxMSW: diff --git a/src/common/event.cpp b/src/common/event.cpp index 31196f57c4..ec31583f0d 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -1084,7 +1084,10 @@ void wxEvtHandler::AddPendingEvent(wxEvent& event) wxENTER_CRIT_SECT( Lock() ); if ( !m_pendingEvents ) + { m_pendingEvents = new wxList; + m_pendingEvents->DeleteContents(true); + } m_pendingEvents->Append(eventCopy); @@ -1126,15 +1129,14 @@ void wxEvtHandler::ProcessPendingEvents() { wxEvent *event = (wxEvent *)node->GetData(); - m_pendingEvents->Erase(node); - wxLEAVE_CRIT_SECT( Lock() ); ProcessEvent(*event); - delete event; wxENTER_CRIT_SECT( Lock() ); + m_pendingEvents->Erase(node); + if ( !--n ) break; } -- 2.45.2