X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f8f7cff4368ee960f63f61d0dd32eacdd471800b..ba86da30cf1a2a8429f3af465cbb6c9f52b307fb:/src/common/event.cpp?ds=sidebyside diff --git a/src/common/event.cpp b/src/common/event.cpp index 7d98a3e6d0..af8b2ac1b2 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -1129,7 +1129,11 @@ void wxEvtHandler::QueueEvent(wxEvent *event) { // we need an event loop which manages the list of event handlers with // pending events... cannot proceed without it! - wxLogDebug("No event loop is running!"); + wxLogDebug("No event loop is running! Cannot queue this event!"); + + // anyway delete the given event to avoid memory leaks + delete event; + return; } @@ -1166,7 +1170,7 @@ void wxEvtHandler::ProcessPendingEvents() { // we need an event loop which manages the list of event handlers with // pending events... cannot proceed without it! - wxLogDebug("No event loop is running!"); + wxLogDebug("No event loop is running! Cannot process pending events!"); return; } @@ -1275,15 +1279,8 @@ wxEvtHandler::ProcessEventIfMatchesId(const wxEventTableEntryBase& entry, return false; } -bool wxEvtHandler::TryParent(wxEvent& event) +bool wxEvtHandler::DoTryApp(wxEvent& event) { - if ( GetNextHandler() ) - { - // the next handler will pass it to wxTheApp if it doesn't process it, - // so return from here to avoid doing it again - return GetNextHandler()->TryParent(event); - } - if ( wxTheApp && (this != wxTheApp) ) { // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always @@ -1299,6 +1296,27 @@ bool wxEvtHandler::TryParent(wxEvent& event) return false; } +bool wxEvtHandler::TryBefore(wxEvent& event) +{ +#ifdef WXWIN_COMPATIBILITY_2_8 + // call the old virtual function to keep the code overriding it working + return TryValidator(event); +#else + wxUnusedVar(event); + return false; +#endif +} + +bool wxEvtHandler::TryAfter(wxEvent& event) +{ +#ifdef WXWIN_COMPATIBILITY_2_8 + // as above, call the old virtual function for compatibility + return TryParent(event); +#else + return DoTryApp(event); +#endif +} + bool wxEvtHandler::ProcessEvent(wxEvent& event) { // allow the application to hook into event processing @@ -1326,14 +1344,14 @@ bool wxEvtHandler::ProcessEvent(wxEvent& event) return true; // pass the event to the next handler, notice that we shouldn't call - // TryParent() even if it doesn't handle the event as the last handler in + // TryAfter() even if it doesn't handle the event as the last handler in // the chain will do it if ( GetNextHandler() ) return GetNextHandler()->ProcessEvent(event); // propagate the event upwards the window chain and/or to the application // object if it wasn't processed at this level - return TryParent(event); + return TryAfter(event); } bool wxEvtHandler::ProcessEventHere(wxEvent& event) @@ -1342,9 +1360,8 @@ bool wxEvtHandler::ProcessEventHere(wxEvent& event) if ( !GetEvtHandlerEnabled() ) return false; - // If we have a validator, it has higher priority than our own event - // handlers - if ( TryValidator(event) ) + // Try the hooks which should be called before our own handlers + if ( TryBefore(event) ) return true; // Handle per-instance dynamic event tables first