X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2c9b3131193fc908c81eb2dc2f23a30c83cc64f4..b9efe021b554fa3967d1442cf758435c5cd5ae8f:/src/common/appbase.cpp diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 0f2c5edd34..0892aab62d 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -68,8 +68,11 @@ #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__ @@ -139,14 +142,6 @@ wxAppConsole::~wxAppConsole() 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; @@ -269,6 +264,11 @@ wxMessageOutput *wxAppConsole::CreateMessageOutput() void wxAppConsole::ProcessPendingEvents() { +#if wxUSE_THREADS + if ( !wxPendingEventsLocker ) + return; +#endif + // ensure that we're the only thread to modify the pending events list wxENTER_CRIT_SECT( *wxPendingEventsLocker ); @@ -288,7 +288,9 @@ void wxAppConsole::ProcessPendingEvents() // In ProcessPendingEvents(), new handlers might be add // and we can safely leave the critical section here. wxLEAVE_CRIT_SECT( *wxPendingEventsLocker ); + handler->ProcessPendingEvents(); + wxENTER_CRIT_SECT( *wxPendingEventsLocker ); node = wxPendingEvents->GetFirst(); @@ -700,35 +702,17 @@ bool DoShowAssertDialog(const wxString& msg) 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: @@ -772,21 +756,53 @@ void ShowAssertDialog(const wxChar *szFile, 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... + 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; - const int maxLines = 10; - // Don't show more than maxLines or we could get an enormous dialog - int count = stackTrace.Freq(wxT('\n')); - if (count > maxLines) + 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 { - int i; - for (i = 0; i < count - maxLines; i++) - stackTrace = stackTrace.BeforeLast(wxT('\n')); + 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