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
This commit is contained in:
Vadim Zeitlin 2005-11-08 00:45:46 +00:00
parent 8fb824187d
commit 6dc2a916df
2 changed files with 6 additions and 3 deletions

View File

@ -29,6 +29,7 @@ All (GUI):
- Added wxBitmapButton::SetHoverBitmap() - Added wxBitmapButton::SetHoverBitmap()
- Access to titles through Get/SetTitle is available now only for top level - Access to titles through Get/SetTitle is available now only for top level
windows (wxDialog, wxFrame). windows (wxDialog, wxFrame).
- Fixed memory leak of pending events in wxEvtHandler
wxMSW: wxMSW:

View File

@ -1084,7 +1084,10 @@ void wxEvtHandler::AddPendingEvent(wxEvent& event)
wxENTER_CRIT_SECT( Lock() ); wxENTER_CRIT_SECT( Lock() );
if ( !m_pendingEvents ) if ( !m_pendingEvents )
{
m_pendingEvents = new wxList; m_pendingEvents = new wxList;
m_pendingEvents->DeleteContents(true);
}
m_pendingEvents->Append(eventCopy); m_pendingEvents->Append(eventCopy);
@ -1126,15 +1129,14 @@ void wxEvtHandler::ProcessPendingEvents()
{ {
wxEvent *event = (wxEvent *)node->GetData(); wxEvent *event = (wxEvent *)node->GetData();
m_pendingEvents->Erase(node);
wxLEAVE_CRIT_SECT( Lock() ); wxLEAVE_CRIT_SECT( Lock() );
ProcessEvent(*event); ProcessEvent(*event);
delete event;
wxENTER_CRIT_SECT( Lock() ); wxENTER_CRIT_SECT( Lock() );
m_pendingEvents->Erase(node);
if ( !--n ) if ( !--n )
break; break;
} }