]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxLog::Suspend/Resume and wxYield() uses them now so that it won't flush
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 22 Feb 2000 10:00:29 +0000 (10:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 22 Feb 2000 10:00:29 +0000 (10:00 +0000)
the messages any more

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

include/wx/log.h
src/common/log.cpp
src/gtk/app.cpp
src/gtk1/app.cpp
src/msw/app.cpp

index 94d0beb5b6aef4d2216cd34f054900efdbe3e571..f5138cf988e40d91f0fbc23a7dbd9e1761c6ca81 100644 (file)
@@ -135,9 +135,12 @@ public:
         // flush the active target if any
     static void FlushActive()
     {
-        wxLog *log = GetActiveTarget();
-        if ( log )
-            log->Flush();
+        if ( !ms_suspendCount )
+        {
+            wxLog *log = GetActiveTarget();
+            if ( log && log->HasPendingMessages() )
+                log->Flush();
+        }
     }
         // get current log target, will call wxApp::CreateLogTarget() to
         // create one if none exists
@@ -145,6 +148,13 @@ public:
         // change log target, pLogger may be NULL
     static wxLog *SetActiveTarget(wxLog *pLogger);
 
+        // suspend the message flushing of the main target until the next call
+        // to Resume() - this is mainly for internal use (to prevent wxYield()
+        // from flashing the messages)
+    static void Suspend() { ms_suspendCount++; }
+        // must be called for each Suspend()!
+    static void Resume() { ms_suspendCount--; }
+
     // functions controlling the default wxLog behaviour
         // verbose mode is activated by standard command-line '-verbose'
         // option
@@ -205,6 +215,8 @@ private:
     static bool        ms_doLog;        // FALSE => all logging disabled
     static bool        ms_bAutoCreate;  // create new log targets on demand?
 
+    static size_t      ms_suspendCount; // if positive, logs are not flushed
+
     // format string for strftime(), if NULL, time stamping log messages is
     // disabled
     static const wxChar *ms_timestamp;
index 2179500499d5863daf550fa0c51e2f7e70da7313..3f062d0dfcb5abd35d342d10f6754ba5a8c046c8 100644 (file)
@@ -448,6 +448,8 @@ wxLog          *wxLog::ms_pLogger      = (wxLog *)NULL;
 bool            wxLog::ms_doLog        = TRUE;
 bool            wxLog::ms_bAutoCreate  = TRUE;
 
+size_t          wxLog::ms_suspendCount = 0;
+
 #if wxUSE_GUI
     const wxChar *wxLog::ms_timestamp  = wxT("%X");  // time only, no date
 #else
index bd85f4f6a252af70362d28001d50208ffd29ac70..b89d77cd5c779f47bfdfa004fb4b4eecaafcc484 100644 (file)
@@ -99,10 +99,18 @@ bool wxYield()
         wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
     }
 
+    // disable log flushing from here because a call to wxYield() shouldn't
+    // normally result in message boxes popping up &c
+    wxLog::Suspend();
+
     /* it's necessary to call ProcessIdle() to update the frames sizes which
        might have been changed (it also will update other things set from
        OnUpdateUI() which is a nice (and desired) side effect) */
-    while (wxTheApp->ProcessIdle()) { }
+    while (wxTheApp->ProcessIdle())
+        ;
+
+    // let the logs be flashed again
+    wxLog::Resume();
 
     return TRUE;
 }
@@ -380,9 +388,7 @@ void wxApp::OnIdle( wxIdleEvent &event )
 
     /* flush the logged messages if any */
 #if wxUSE_LOG
-    wxLog *log = wxLog::GetActiveTarget();
-    if (log != NULL && log->HasPendingMessages())
-        log->Flush();
+    wxLog::FlushActive();
 #endif // wxUSE_LOG
 }
 
index bd85f4f6a252af70362d28001d50208ffd29ac70..b89d77cd5c779f47bfdfa004fb4b4eecaafcc484 100644 (file)
@@ -99,10 +99,18 @@ bool wxYield()
         wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
     }
 
+    // disable log flushing from here because a call to wxYield() shouldn't
+    // normally result in message boxes popping up &c
+    wxLog::Suspend();
+
     /* it's necessary to call ProcessIdle() to update the frames sizes which
        might have been changed (it also will update other things set from
        OnUpdateUI() which is a nice (and desired) side effect) */
-    while (wxTheApp->ProcessIdle()) { }
+    while (wxTheApp->ProcessIdle())
+        ;
+
+    // let the logs be flashed again
+    wxLog::Resume();
 
     return TRUE;
 }
@@ -380,9 +388,7 @@ void wxApp::OnIdle( wxIdleEvent &event )
 
     /* flush the logged messages if any */
 #if wxUSE_LOG
-    wxLog *log = wxLog::GetActiveTarget();
-    if (log != NULL && log->HasPendingMessages())
-        log->Flush();
+    wxLog::FlushActive();
 #endif // wxUSE_LOG
 }
 
index 25181c2d11594bb15af85591585a3f789e045792..94c9239a6dece9889408e2b6528964802c891615 100644 (file)
@@ -1019,9 +1019,7 @@ void wxApp::OnIdle(wxIdleEvent& event)
 
 #if wxUSE_LOG
     // flush the logged messages if any
-    wxLog *pLog = wxLog::GetActiveTarget();
-    if ( pLog != NULL && pLog->HasPendingMessages() )
-        pLog->Flush();
+    wxLog::FlushActive();
 #endif // wxUSE_LOG
 
     // Send OnIdle events to all windows
@@ -1216,9 +1214,12 @@ void wxExit()
 // Yield to incoming messages
 bool wxYield()
 {
+    // disable log flushing from here because a call to wxYield() shouldn't
+    // normally result in message boxes popping up &c
+    wxLog::Suspend();
+
     // we don't want to process WM_QUIT from here - it should be processed in
     // the main event loop in order to stop it
-
     MSG msg;
     while ( PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) &&
             msg.message != WM_QUIT )
@@ -1234,6 +1235,9 @@ bool wxYield()
     // If they are pending events, we must process them.
     wxTheApp->ProcessPendingEvents();
 
+    // let the logs be flashed again
+    wxLog::Resume();
+
     return TRUE;
 }