]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/event.cpp
fix memory leak of wxMessageOutput if wxApp::OnInit() returned false
[wxWidgets.git] / src / common / event.cpp
index 7bb9ba699dfab4ec1b97b804a6e8f9b251f4b8ca..ec31583f0d0caaf600a64b0a9b1fa56db211866e 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && !defined(__EMX__)
-// Some older compilers (such as EMX) cannot handle
-// #pragma interface/implementation correctly, iff
-// #pragma implementation is used in _two_ translation
-// units (as created by e.g. event.cpp compiled for
-// libwx_base and event.cpp compiled for libwx_gui_core).
-// So we must not use those pragmas for those compilers in
-// such files.
-    #pragma implementation "event.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -245,7 +234,7 @@ DEFINE_EVENT_TYPE(wxEVT_SCROLL_PAGEUP)
 DEFINE_EVENT_TYPE(wxEVT_SCROLL_PAGEDOWN)
 DEFINE_EVENT_TYPE(wxEVT_SCROLL_THUMBTRACK)
 DEFINE_EVENT_TYPE(wxEVT_SCROLL_THUMBRELEASE)
-DEFINE_EVENT_TYPE(wxEVT_SCROLL_ENDSCROLL)
+DEFINE_EVENT_TYPE(wxEVT_SCROLL_CHANGED)
 
 // Scroll events from wxWindow
 DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_TOP)
@@ -1044,8 +1033,10 @@ wxEvtHandler::~wxEvtHandler()
     // Remove us from wxPendingEvents if necessary.
     if(wxPendingEventsLocker)
         wxENTER_CRIT_SECT(*wxPendingEventsLocker);
-    if ( wxPendingEvents ) {
-        wxPendingEvents->DeleteObject(this);
+    if ( wxPendingEvents )
+    {
+        // Delete all occurences of this from the list of pending events
+        while (wxPendingEvents->DeleteObject(this)) { } // Do nothing
     }
     if(wxPendingEventsLocker)
         wxLEAVE_CRIT_SECT(*wxPendingEventsLocker);
@@ -1075,7 +1066,7 @@ void wxEvtHandler::ClearEventLocker()
     delete m_eventsLocker;
     m_eventsLocker = NULL;
 #endif
-};
+}
 
 #endif // wxUSE_THREADS
 
@@ -1093,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);
 
@@ -1135,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;
     }
@@ -1368,7 +1361,7 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event )
     }
 
     return false;
-};
+}
 
 void wxEvtHandler::DoSetClientObject( wxClientData *data )
 {