added wxLog::Suspend/Resume and wxYield() uses them now so that it won't flush
the messages any more git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6204 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -134,17 +134,27 @@ public:
|
||||
// only one sink is active at each moment
|
||||
// flush the active target if any
|
||||
static void FlushActive()
|
||||
{
|
||||
if ( !ms_suspendCount )
|
||||
{
|
||||
wxLog *log = GetActiveTarget();
|
||||
if ( log )
|
||||
if ( log && log->HasPendingMessages() )
|
||||
log->Flush();
|
||||
}
|
||||
}
|
||||
// get current log target, will call wxApp::CreateLogTarget() to
|
||||
// create one if none exists
|
||||
static wxLog *GetActiveTarget();
|
||||
// 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;
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user