]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/appcmn.cpp
fixing overrelease and out-of-bounds write, fixes #13725
[wxWidgets.git] / src / common / appcmn.cpp
index 003debce41f173b30e88e8c89fb67c14182cc4b6..9a3ead6a33da8b33425146009df9afb0fca625fc 100644 (file)
@@ -128,8 +128,7 @@ void wxAppBase::CleanUp()
 
     wxDeleteStockLists();
 
-    delete wxTheColourDatabase;
-    wxTheColourDatabase = NULL;
+    wxDELETE(wxTheColourDatabase);
 
     wxAppConsole::CleanUp();
 }
@@ -197,10 +196,10 @@ void wxAppBase::OnInitCmdLine(wxCmdLineParser& parser)
         },
 #endif // __WXUNIVERSAL__
 
-#if defined(__WXMGL__)
-        // VS: this is not specific to wxMGL, all fullscreen (framebuffer) ports
+#if defined(__WXDFB__)
+        // VS: this is not specific to wxDFB, all fullscreen (framebuffer) ports
         //     should provide this option. That's why it is in common/appcmn.cpp
-        //     and not mgl/app.cpp
+        //     and not dfb/app.cpp
         {
             wxCMD_LINE_OPTION,
             NULL,
@@ -209,7 +208,7 @@ void wxAppBase::OnInitCmdLine(wxCmdLineParser& parser)
             wxCMD_LINE_VAL_STRING,
             0x0
         },
-#endif // __WXMGL__
+#endif // __WXDFB__
 
         // terminator
         wxCMD_LINE_DESC_END
@@ -237,7 +236,7 @@ bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser)
     }
 #endif // __WXUNIVERSAL__
 
-#if defined(__WXMGL__)
+#if defined(__WXDFB__)
     wxString modeDesc;
     if ( parser.Found(OPTION_MODE, &modeDesc) )
     {
@@ -251,7 +250,7 @@ bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser)
         if ( !SetDisplayMode(wxVideoMode(w, h, bpp)) )
             return false;
     }
-#endif // __WXMGL__
+#endif // __WXDFB__
 
     return wxAppConsole::OnCmdLineParsed(parser);
 }
@@ -350,7 +349,10 @@ bool wxAppBase::ProcessIdle()
     while (node)
     {
         wxWindow* win = node->GetData();
-        if (SendIdleEvents(win, event))
+
+        // Don't send idle events to the windows that are about to be destroyed
+        // anyhow, this is wasteful and unexpected.
+        if ( !wxPendingDelete.Member(win) && win->SendIdleEvents(event) )
             needMore = true;
         node = node->GetNext();
     }
@@ -360,36 +362,6 @@ bool wxAppBase::ProcessIdle()
     return needMore;
 }
 
-// Send idle event to window and all subwindows
-bool wxAppBase::SendIdleEvents(wxWindow* win, wxIdleEvent& event)
-{
-    bool needMore = false;
-
-    win->OnInternalIdle();
-
-    // should we send idle event to this window?
-    if ( wxIdleEvent::GetMode() == wxIDLE_PROCESS_ALL ||
-            win->HasExtraStyle(wxWS_EX_PROCESS_IDLE) )
-    {
-        event.SetEventObject(win);
-        win->HandleWindowEvent(event);
-
-        if (event.MoreRequested())
-            needMore = true;
-    }
-    wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst();
-    while ( node )
-    {
-        wxWindow *child = node->GetData();
-        if (SendIdleEvents(child, event))
-            needMore = true;
-
-        node = node->GetNext();
-    }
-
-    return needMore;
-}
-
 // ----------------------------------------------------------------------------
 // wxGUIAppTraitsBase
 // ----------------------------------------------------------------------------
@@ -399,7 +371,11 @@ bool wxAppBase::SendIdleEvents(wxWindow* win, wxIdleEvent& event)
 wxLog *wxGUIAppTraitsBase::CreateLogTarget()
 {
 #if wxUSE_LOGGUI
+#ifndef __WXOSX_IPHONE__
     return new wxLogGui;
+#else
+    return new wxLogStderr;
+#endif
 #else
     // we must have something!
     return new wxLogStderr;