]> git.saurik.com Git - wxWidgets.git/commitdiff
Implemented wxEntryStart, wxEntryInitGui, wxEntryCleanup.
authorMattia Barbon <mbarbon@cpan.org>
Sat, 26 Apr 2003 12:54:45 +0000 (12:54 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Sat, 26 Apr 2003 12:54:45 +0000 (12:54 +0000)
  Removed code already in wxTopLevelWindowBase.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20351 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/motif/app.cpp
src/motif/toplevel.cpp

index 63cfd7ab1cc754674a395f19d3ad6ee76d904196..1dce3f1186a84fd6decda4f2e2684442f4bb6cb1 100644 (file)
 #define XtDisplay XTDISPLAY
 #endif
 
-#include "wx/frame.h"
 #include "wx/app.h"
 #include "wx/utils.h"
-#include "wx/gdicmn.h"
-#include "wx/pen.h"
-#include "wx/brush.h"
-#include "wx/cursor.h"
-#include "wx/icon.h"
-#include "wx/palette.h"
-#include "wx/dc.h"
-#include "wx/dialog.h"
-#include "wx/msgdlg.h"
-#include "wx/log.h"
 #include "wx/module.h"
 #include "wx/memory.h"
 #include "wx/log.h"
@@ -114,9 +103,6 @@ bool wxApp::Initialize()
 
 void wxApp::CleanUp()
 {
-    delete wxWidgetHashTable;
-    wxWidgetHashTable = NULL;
-
     wxModule::CleanUpModules();
 
     wxDeleteStockObjects() ;
@@ -133,6 +119,9 @@ void wxApp::CleanUp()
     delete wxTheApp;
     wxTheApp = NULL;
 
+    delete wxWidgetHashTable;
+    wxWidgetHashTable = NULL;
+
     // GL: I'm annoyed ... I don't know where to put this and I don't want to
     // create a module for that as it's part of the core.
 #if wxUSE_THREADS
@@ -159,7 +148,11 @@ void wxApp::CleanUp()
     delete wxLog::SetActiveTarget(NULL);
 }
 
-int wxEntry( int argc, char *argv[] )
+// ============================================================================
+// wxEntry*
+// ============================================================================
+
+int wxEntryStart( int argc, char* argv[] )
 {
 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
     // This seems to be necessary since there are 'rogue'
@@ -172,7 +165,41 @@ int wxEntry( int argc, char *argv[] )
 #endif
 
     if (!wxApp::Initialize())
-        return FALSE;
+        return -1;
+
+    return 0;
+}
+
+int wxEntryInitGui()
+{
+    int retValue = 0;
+
+    // GUI-specific initialization, such as creating an app context.
+    if (!wxTheApp->OnInitGui())
+        retValue = -1;
+
+    return retValue;
+}
+
+void wxEntryCleanup()
+{
+    // So dialog boxes aren't used for further messages
+    delete wxLog::SetActiveTarget(new wxLogStderr);
+
+    // flush the logged messages if any
+    wxLog *pLog = wxLog::GetActiveTarget();
+    if ( pLog != NULL && pLog->HasPendingMessages() )
+        pLog->Flush();
+
+    wxApp::CleanUp();
+}
+
+int wxEntry( int argc, char *argv[] )
+{
+    int retValue = 0;
+
+    retValue = wxEntryStart( argc, argv );
+    if (retValue) return retValue;
 
     if (!wxTheApp)
     {
@@ -198,25 +225,18 @@ int wxEntry( int argc, char *argv[] )
     wxTheApp->argv = argv;
 
     // GUI-specific initialization, such as creating an app context.
-    wxTheApp->OnInitGui();
+    retValue = wxEntryInitGui();
+    if (retValue) return retValue;
 
     // Here frames insert themselves automatically into wxTopLevelWindows by
     // getting created in OnInit().
 
-    int retValue = 0;
     if (wxTheApp->OnInit())
     {
-        if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
+        if (wxTheApp->Initialized())
+            wxTheApp->OnRun();
     }
 
-    // flush the logged messages if any
-    wxLog *pLog = wxLog::GetActiveTarget();
-    if ( pLog != NULL && pLog->HasPendingMessages() )
-        pLog->Flush();
-
-    // So dialog boxes aren't used for further messages
-    delete wxLog::SetActiveTarget(new wxLogStderr);
-
     if (wxTheApp->GetTopWindow())
     {
         delete wxTheApp->GetTopWindow();
@@ -225,12 +245,12 @@ int wxEntry( int argc, char *argv[] )
 
     wxTheApp->DeletePendingObjects();
 
-    wxTheApp->OnExit();
+    retValue = wxTheApp->OnExit();
 
-    wxApp::CleanUp();
+    wxEntryCleanup();
 
     return retValue;
-};
+}
 
 // Static member initialization
 wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
@@ -300,7 +320,8 @@ bool wxApp::ProcessIdle()
 
 void wxApp::ExitMainLoop()
 {
-    m_eventLoop->Exit();
+    if( m_eventLoop->IsRunning() )
+        m_eventLoop->Exit();
 }
 
 // Is a message/event pending?
index 8b54b2175c7239e9f0ce93f74166dd698d1123a5..9ce63d5fd62e94464337a4092f330885ade4129e 100644 (file)
@@ -66,8 +66,6 @@ static void wxTLWEventHandler( Widget wid,
 
 void wxTopLevelWindowMotif::PreDestroy()
 {
-    wxTopLevelWindows.DeleteObject(this);
-
     if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
         wxModelessWindows.DeleteObject(this);
 
@@ -90,17 +88,6 @@ void wxTopLevelWindowMotif::PreDestroy()
 wxTopLevelWindowMotif::~wxTopLevelWindowMotif()
 {
     SetMainWidget( (WXWidget)0 );
-
-    // If this is the last top-level window, exit.
-    if (wxTheApp && (wxTopLevelWindows.GetCount() == 0))
-    {
-        wxTheApp->SetTopWindow(NULL);
-
-        if (wxTheApp->GetExitOnFrameDelete())
-        {
-            wxTheApp->ExitMainLoop();
-        }
-    }
 }
 
 void wxTopLevelWindowMotif::Init()