// Author: Vadim Zeitlin
// Modified by:
// Created: 19.06.2003 (extracted from common/appcmn.cpp)
-// RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
bool wxAppConsoleBase::Initialize(int& WXUNUSED(argc), wxChar **WXUNUSED(argv))
{
-#if wxUSE_INTL
- GetTraits()->SetLocale();
-#endif // wxUSE_INTL
-
return true;
}
return MainLoop();
}
+void wxAppConsoleBase::OnLaunched()
+{
+}
+
int wxAppConsoleBase::OnExit()
{
#if wxUSE_CONFIG
return app ? app->GetTraits() : NULL;
}
+/* static */
+wxAppTraits& wxAppConsoleBase::GetValidTraits()
+{
+ static wxConsoleAppTraits s_traitsConsole;
+ wxAppTraits* const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
+
+ return traits ? *traits : s_traitsConsole;
+}
+
// ----------------------------------------------------------------------------
// wxEventLoop redirection
// ----------------------------------------------------------------------------
{
wxEventLoopBaseTiedPtr mainLoop(&m_mainLoop, CreateMainLoop());
+ if (wxTheApp)
+ wxTheApp->OnLaunched();
+
return m_mainLoop ? m_mainLoop->Run() : -1;
}
OnAssertFailure(file, line, NULL, cond, msg);
}
+// ----------------------------------------------------------------------------
+// Miscellaneous other methods
+// ----------------------------------------------------------------------------
+
+void wxAppConsoleBase::SetCLocale()
+{
+ // We want to use the user locale by default in GUI applications in order
+ // to show the numbers, dates &c in the familiar format -- and also accept
+ // this format on input (especially important for decimal comma/dot).
+ wxSetlocale(LC_ALL, "");
+}
+
// ============================================================================
// other classes implementations
// ============================================================================
// wxAppTraits
// ----------------------------------------------------------------------------
-#if wxUSE_INTL
-void wxAppTraitsBase::SetLocale()
-{
- // We want to use the user locale by default in GUI applications in order
- // to show the numbers, dates &c in the familiar format -- and also accept
- // this format on input (especially important for decimal comma/dot).
- wxSetlocale(LC_ALL, "");
-
-#if wxUSE_STL
- // At least in some environments, e.g. MinGW-64, if the global C++ locale
- // is different from the global C locale, all stream operations temporarily
- // change the locale resulting in a huge slowdown (3 times slower in some
- // real-life applications), so change the C++ locale to match.
- std::locale::global(std::locale(""));
-#endif //wxUSE_STL
-
- wxUpdateLocaleIsUtf8();
-}
-#endif
-
#if wxUSE_THREADS
void wxMutexGuiEnterImpl();
void wxMutexGuiLeaveImpl();
#if wxDEBUG_LEVEL
// break into the debugger
+#ifndef wxTrap
+
void wxTrap()
{
#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
#endif // Win/Unix
}
+#endif // wxTrap already defined as a macro
+
// default assert handler
static void
wxDefaultAssertHandler(const wxString& file,
#if wxDEBUG_LEVEL
+bool wxTrapInAssert = false;
+
static
bool DoShowAssertDialog(const wxString& msg)
{
MB_YESNOCANCEL | MB_ICONSTOP ) )
{
case IDYES:
- wxTrap();
+ // If we called wxTrap() directly from here, the programmer would
+ // see this function and a few more calls between his own code and
+ // it in the stack trace which would be perfectly useless and often
+ // confusing. So instead just set the flag here and let the macros
+ // defined in wx/debug.h call wxTrap() themselves, this ensures
+ // that the debugger will show the line in the user code containing
+ // the failing assert.
+ wxTrapInAssert = true;
break;
case IDCANCEL: