]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/appcmn.cpp
fixed VC++ warning in release build
[wxWidgets.git] / src / common / appcmn.cpp
index 2652222813a3b2965624d1d8abf63e077a9f58e6..598204ad13ea33525326119f92dad8599717819c 100644 (file)
 
 #ifndef WX_PRECOMP
     #include "wx/app.h"
+    #include "wx/bitmap.h"
     #include "wx/intl.h"
     #include "wx/list.h"
+    #include "wx/log.h"
     #include "wx/msgdlg.h"
 #endif
 
@@ -48,7 +50,7 @@
 // ============================================================================
 
 // ----------------------------------------------------------------------------
-// initialization and termination
+// initialization
 // ----------------------------------------------------------------------------
 
 wxAppBase::wxAppBase()
@@ -72,11 +74,67 @@ wxAppBase::wxAppBase()
     m_exitOnFrameDelete = Later;
 }
 
+bool wxAppBase::Initialize(int& argc, wxChar **argv)
+{
+    if ( !wxAppConsole::Initialize(argc, argv) )
+        return false;
+
+#if wxUSE_THREADS
+    wxPendingEventsLocker = new wxCriticalSection;
+#endif
+
+    wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
+    wxTheColourDatabase->Initialize();
+
+    wxInitializeStockLists();
+    wxInitializeStockObjects();
+
+    wxBitmap::InitStandardHandlers();
+
+    return true;
+}
+
+// ----------------------------------------------------------------------------
+// cleanup
+// ----------------------------------------------------------------------------
+
 wxAppBase::~wxAppBase()
 {
     // this destructor is required for Darwin
 }
 
+void wxAppBase::CleanUp()
+{
+    // one last chance for pending objects to be cleaned up
+    DeletePendingObjects();
+
+    wxBitmap::CleanUpHandlers();
+
+    wxDeleteStockObjects();
+
+    wxDeleteStockLists();
+
+    delete wxTheColourDatabase;
+    wxTheColourDatabase = NULL;
+
+#if wxUSE_THREADS
+    delete wxPendingEvents;
+    wxPendingEvents = NULL;
+
+    delete wxPendingEventsLocker;
+    wxPendingEventsLocker = NULL;
+
+#if wxUSE_VALIDATORS
+    // If we don't do the following, we get an apparent memory leak.
+    ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
+#endif // wxUSE_VALIDATORS
+#endif // wxUSE_THREADS
+}
+
+// ----------------------------------------------------------------------------
+// OnXXX() hooks
+// ----------------------------------------------------------------------------
+
 bool wxAppBase::OnInitGui()
 {
 #ifdef __WXUNIVERSAL__
@@ -127,6 +185,24 @@ void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus))
     (void)ProcessEvent(event);
 }
 
+void wxAppBase::DeletePendingObjects()
+{
+    wxNode *node = wxPendingDelete.GetFirst();
+    while (node)
+    {
+        wxObject *obj = node->GetData();
+
+        delete obj;
+
+        if (wxPendingDelete.Member(obj))
+            delete node;
+
+        // Deleting one object may have deleted other pending
+        // objects, so start from beginning of list again.
+        node = wxPendingDelete.GetFirst();
+    }
+}
+
 // ----------------------------------------------------------------------------
 // wxGUIAppTraitsBase
 // ----------------------------------------------------------------------------