// Created: 19.06.2003 (extracted from common/appcmn.cpp)
// RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
-// License: wxWindows license
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
#include "wx/filename.h"
#include "wx/msgout.h"
#include "wx/scopedptr.h"
+#include "wx/sysopt.h"
#include "wx/tokenzr.h"
#include "wx/thread.h"
// In unicode mode the SetTraceMasks call can cause an apptraits to be
// created, but since we are still in the constructor the wrong kind will
// be created for GUI apps. Destroy it so it can be created again later.
- delete m_traits;
- m_traits = NULL;
+ wxDELETE(m_traits);
#endif
#endif
}
void wxAppConsoleBase::CleanUp()
{
- if ( m_mainLoop )
- {
- delete m_mainLoop;
- m_mainLoop = NULL;
- }
+ wxDELETE(m_mainLoop);
}
// ----------------------------------------------------------------------------
bool wxAppConsoleBase::Yield(bool onlyIfNeeded)
{
wxEventLoopBase * const loop = wxEventLoopBase::GetActive();
+ if ( loop )
+ return loop->Yield(onlyIfNeeded);
- return loop && loop->Yield(onlyIfNeeded);
+ wxScopedPtr<wxEventLoopBase> tmpLoop(CreateMainLoop());
+ return tmpLoop->Yield(onlyIfNeeded);
}
void wxAppConsoleBase::WakeUpIdle()
wxLog::FlushActive();
#endif
+ // Garbage collect all objects previously scheduled for destruction.
+ DeletePendingObjects();
+
return event.MoreRequested();
}
wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
}
-
- // Garbage collect all objects previously scheduled for destruction.
- DeletePendingObjects();
}
void wxAppConsoleBase::DeletePendingEvents()
bool wxAppTraitsBase::ShowAssertDialog(const wxString& msgOriginal)
{
#if wxDEBUG_LEVEL
- wxString msg = msgOriginal;
+ wxString msg;
#if wxUSE_STACKWALKER
-#if !defined(__WXMSW__)
- // on Unix stack frame generation may take some time, depending on the
- // size of the executable mainly... warn the user that we are working
- wxFprintf(stderr, wxT("[Debug] Generating a stack trace... please wait"));
- fflush(stderr);
-#endif
-
const wxString stackTrace = GetAssertStackTrace();
if ( !stackTrace.empty() )
+ {
msg << wxT("\n\nCall stack:\n") << stackTrace;
+
+ wxMessageOutputDebug().Output(msg);
+ }
#endif // wxUSE_STACKWALKER
- return DoShowAssertDialog(msg);
+ return DoShowAssertDialog(msgOriginal + msg);
#else // !wxDEBUG_LEVEL
wxUnusedVar(msgOriginal);
wxString wxAppTraitsBase::GetAssertStackTrace()
{
#if wxDEBUG_LEVEL
+
+#if !defined(__WXMSW__)
+ // on Unix stack frame generation may take some time, depending on the
+ // size of the executable mainly... warn the user that we are working
+ wxFprintf(stderr, "Collecting stack trace information, please wait...");
+ fflush(stderr);
+#endif // !__WXMSW__
+
+
wxString stackTrace;
class StackDump : public wxStackWalker
const wxString& cond,
const wxString& msg)
{
+ // If this option is set, we should abort immediately when assert happens.
+ if ( wxSystemOptions::GetOptionInt("exit-on-assert") )
+ abort();
+
// FIXME MT-unsafe
static int s_bInAssert = 0;
//case IDNO: nothing to do
}
#else // !__WXMSW__
- wxMessageOutputDebug().Output(msg);
-
- // TODO: ask the user whether to trap on the console?
+ wxUnusedVar(msg);
#endif // __WXMSW__/!__WXMSW__
- // continue with the asserts
+ // continue with the asserts by default
return false;
}