#include "wx/ptr_scpd.h"
#include "wx/tokenzr.h"
+#if wxUSE_EXCEPTIONS && wxUSE_STL
+ #include <exception>
+ #include <typeinfo>
+#endif
+
#if !defined(__WXMSW__) || defined(__WXMICROWIN__)
#include <signal.h> // for SIGTRAP used by wxTrap()
#endif //Win/Unix
bool wxAppConsoleBase::HasPendingEvents() const
{
- // ensure that we're the only thread to modify the pending events list
wxENTER_CRIT_SECT( *wxPendingEventsLocker );
- if ( !wxPendingEvents )
- {
- wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
- return false;
- }
+ bool has = wxPendingEvents && !wxPendingEvents->IsEmpty();
+
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
- return true;
+
+ return has;
}
/* static */
return;
#endif
- if ( !HasPendingEvents() )
- return;
-
wxENTER_CRIT_SECT( *wxPendingEventsLocker );
- // iterate until the list becomes empty
- wxList::compatibility_iterator node = wxPendingEvents->GetFirst();
- while (node)
+ if (wxPendingEvents)
{
- wxEvtHandler *handler = (wxEvtHandler *)node->GetData();
- wxPendingEvents->Erase(node);
+ // iterate until the list becomes empty
+ wxList::compatibility_iterator node = wxPendingEvents->GetFirst();
+ while (node)
+ {
+ wxEvtHandler *handler = (wxEvtHandler *)node->GetData();
+ wxPendingEvents->Erase(node);
- // In ProcessPendingEvents(), new handlers might be add
- // and we can safely leave the critical section here.
- wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
+ // In ProcessPendingEvents(), new handlers might be add
+ // and we can safely leave the critical section here.
+ wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
- handler->ProcessPendingEvents();
+ handler->ProcessPendingEvents();
- wxENTER_CRIT_SECT( *wxPendingEventsLocker );
+ wxENTER_CRIT_SECT( *wxPendingEventsLocker );
- node = wxPendingEvents->GetFirst();
+ node = wxPendingEvents->GetFirst();
+ }
}
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
(handler->*func)(event);
}
+void wxAppConsoleBase::OnUnhandledException()
+{
+#ifdef __WXDEBUG__
+ // we're called from an exception handler so we can re-throw the exception
+ // to recover its type
+ wxString what;
+ try
+ {
+ throw;
+ }
+#if wxUSE_STL
+ catch ( std::exception& e )
+ {
+ what.Printf("std::exception of type \"%s\", what() = \"%s\"",
+ typeid(e).name(), e.what());
+ }
+#endif // wxUSE_STL
+ catch ( ... )
+ {
+ what = "unknown exception";
+ }
+
+ wxMessageOutputBest().Printf(
+ "*** Caught unhandled %s; terminating\n", what
+ );
+#endif // __WXDEBUG__
+}
+
// ----------------------------------------------------------------------------
// exceptions support
// ----------------------------------------------------------------------------
-#if wxUSE_EXCEPTIONS
-
bool wxAppConsoleBase::OnExceptionInMainLoop()
{
throw;
#endif
}
-#endif // wxUSE_EXCEPTIONS
-
-
#endif // wxUSE_EXCEPTIONS
// ----------------------------------------------------------------------------
#if wxUSE_INTL
void wxAppTraitsBase::SetLocale()
{
- setlocale(LC_ALL, "");
+ wxSetlocale(LC_ALL, "");
wxUpdateLocaleIsUtf8();
}
#endif
#endif // wxUSE_LOG
}
+static
bool DoShowAssertDialog(const wxString& msg)
{
// under MSW we can show the dialog even in the console mode
wxT("You can also choose [Cancel] to suppress ")
wxT("further warnings.");
- switch ( ::MessageBox(NULL, msgDlg, _T("wxWidgets Debug Alert"),
+ switch ( ::MessageBox(NULL, msgDlg.wx_str(), _T("wxWidgets Debug Alert"),
MB_YESNOCANCEL | MB_ICONSTOP ) )
{
case IDYES:
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
msg << wxT("\r\n");
- OutputDebugString(msg );
+ OutputDebugString(msg.wx_str());
#else
// send to stderr
wxFprintf(stderr, wxT("%s\n"), msg.c_str());