#endif // __WXMAC__
#ifdef __WXDEBUG__
- #ifdef wxUSE_STACKWALKER
+ #if wxUSE_STACKWALKER
#include "wx/stackwalk.h"
+ #ifdef __WXMSW__
+ #include "wx/msw/debughlp.h"
+ #endif
#endif // wxUSE_STACKWALKER
#endif // __WXDEBUG__
bool wxAppConsole::Initialize(int& argc, wxChar **argv)
{
-#if wxUSE_LOG
- // If some code logged something before wxApp instance was created,
- // wxLogStderr was set as the target. Undo it here by destroying the
- // current target. It will be re-created next time logging is needed, but
- // this time wxAppTraits will be used:
- delete wxLog::SetActiveTarget(NULL);
-#endif // wxUSE_LOG
-
// remember the command line arguments
this->argc = argc;
this->argv = argv;
#if wxUSE_THREADS
if ( !wxPendingEventsLocker )
return;
+#endif
// ensure that we're the only thread to modify the pending events list
wxENTER_CRIT_SECT( *wxPendingEventsLocker );
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
return;
}
-#endif
// iterate until the list becomes empty
wxList::compatibility_iterator node = wxPendingEvents->GetFirst();
wxEvtHandler *handler = (wxEvtHandler *)node->GetData();
wxPendingEvents->Erase(node);
-#if wxUSE_THREADS
// In ProcessPendingEvents(), new handlers might be add
// and we can safely leave the critical section here.
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
-#endif
handler->ProcessPendingEvents();
-#if wxUSE_THREADS
wxENTER_CRIT_SECT( *wxPendingEventsLocker );
-#endif
node = wxPendingEvents->GetFirst();
}
-#if wxUSE_THREADS
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
-#endif
}
int wxAppConsole::FilterEvent(wxEvent& WXUNUSED(event))
return false;
}
-// show the assert modal dialog
-static
-void ShowAssertDialog(const wxChar *szFile,
- int nLine,
- const wxChar *szCond,
- const wxChar *szMsg,
- wxAppTraits *traits)
+#if wxUSE_STACKWALKER
+static wxString GetAssertStackTrace()
{
- // this variable can be set to true to suppress "assert failure" messages
- static bool s_bNoAsserts = false;
-
- wxString msg;
- msg.reserve(2048);
-
- // make life easier for people using VC++ IDE by using this format: like
- // this, clicking on the message will take us immediately to the place of
- // the failed assert
- msg.Printf(wxT("%s(%d): assert \"%s\" failed"), szFile, nLine, szCond);
-
- if ( szMsg )
- {
- msg << _T(": ") << szMsg;
- }
- else // no message given
- {
- msg << _T('.');
- }
+ wxString stackTrace;
-#if wxUSE_STACKWALKER
+#if wxUSE_DBGHELP
+ // check that we can get the stack trace before trying to do it
+ if ( !wxDbgHelpDLL::Init() )
+ return stackTrace;
+#endif
+
class StackDump : public wxStackWalker
{
public:
StackDump dump;
dump.Walk(5); // don't show OnAssert() call itself
- wxString stackTrace = dump.GetStackTrace();
+ stackTrace = dump.GetStackTrace();
// don't show more than maxLines or we could get a dialog too tall to be
// shown on screen: 20 should be ok everywhere as even with 15 pixel high
// characters it is still only 300 pixels...
- const int maxLines = 20;
- int count = stackTrace.Freq(wxT('\n'));
- if (count > maxLines)
+ static const int maxLines = 20;
+ const int count = stackTrace.Freq(wxT('\n'));
+ for ( int i = 0; i < count - maxLines; i++ )
+ stackTrace = stackTrace.BeforeLast(wxT('\n'));
+
+ return stackTrace;
+}
+#endif // wxUSE_STACKWALKER
+
+// show the assert modal dialog
+static
+void ShowAssertDialog(const wxChar *szFile,
+ int nLine,
+ const wxChar *szCond,
+ const wxChar *szMsg,
+ wxAppTraits *traits)
+{
+ // this variable can be set to true to suppress "assert failure" messages
+ static bool s_bNoAsserts = false;
+
+ wxString msg;
+ msg.reserve(2048);
+
+ // make life easier for people using VC++ IDE by using this format: like
+ // this, clicking on the message will take us immediately to the place of
+ // the failed assert
+ msg.Printf(wxT("%s(%d): assert \"%s\" failed"), szFile, nLine, szCond);
+
+ if ( szMsg )
{
- int i;
- for (i = 0; i < count - maxLines; i++)
- stackTrace = stackTrace.BeforeLast(wxT('\n'));
+ msg << _T(": ") << szMsg;
}
+ else // no message given
+ {
+ msg << _T('.');
+ }
+
+#if wxUSE_STACKWALKER
+ const wxString stackTrace = GetAssertStackTrace();
if ( !stackTrace.empty() )
{
- msg << _T("\n\nCall stack:\n")
- << stackTrace;
+ msg << _T("\n\nCall stack:\n") << stackTrace;
}
#endif // wxUSE_STACKWALKER