#include "wx/evtloop.h"
#include "wx/filename.h"
#include "wx/msgout.h"
-#include "wx/ptr_scpd.h"
+#include "wx/scopedptr.h"
#include "wx/tokenzr.h"
+#include "wx/thread.h"
#if wxUSE_EXCEPTIONS && wxUSE_STL
#include <exception>
#include <typeinfo>
#endif
+#ifndef __WXPALMOS5__
#if !defined(__WXMSW__) || defined(__WXMICROWIN__)
#include <signal.h> // for SIGTRAP used by wxTrap()
#endif //Win/Unix
#include <locale.h>
+#endif // ! __WXPALMOS5__
#if wxUSE_FONTMAP
#include "wx/fontmap.h"
#endif // wxUSE_FONTMAP
-#if defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
- // For MacTypes.h for Debugger function
- #include <CoreFoundation/CFBase.h>
-#endif
-
-#if defined(__WXMAC__)
- #ifdef __DARWIN__
- #include <CoreServices/CoreServices.h>
- #else
- #include "wx/mac/private.h" // includes mac headers
- #endif
-#endif // __WXMAC__
-
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL
#if wxUSE_STACKWALKER
#include "wx/stackwalk.h"
#ifdef __WXMSW__
#include "wx/msw/debughlp.h"
#endif
#endif // wxUSE_STACKWALKER
-#endif // __WXDEBUG__
+
+ #include "wx/recguard.h"
+#endif // wxDEBUG_LEVEL
// wxABI_VERSION can be defined when compiling applications but it should be
// left undefined when compiling the library itself, it is then set to its
// private functions prototypes
// ----------------------------------------------------------------------------
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL
// really just show the assert dialog
static bool DoShowAssertDialog(const wxString& msg);
// prepare for showing the assert dialog, use the given traits or
// DoShowAssertDialog() as last fallback to really show it
static
- void ShowAssertDialog(const wxString& szFile,
- int nLine,
- const wxString& szFunc,
- const wxString& szCond,
- const wxString& szMsg,
+ void ShowAssertDialog(const wxString& file,
+ int line,
+ const wxString& func,
+ const wxString& cond,
+ const wxString& msg,
wxAppTraits *traits = NULL);
+#endif // wxDEBUG_LEVEL
+#ifdef __WXDEBUG__
// turn on the trace masks specified in the env variable WXTRACE
static void LINKAGEMODE SetTraceMasks();
#endif // __WXDEBUG__
wxAppInitializerFunction wxAppConsoleBase::ms_appInitFn = NULL;
+wxSocketManager *wxAppTraitsBase::ms_manager = NULL;
+
// ----------------------------------------------------------------------------
// wxEventLoopPtr
// ----------------------------------------------------------------------------
{
m_traits = NULL;
m_mainLoop = NULL;
+ m_bDoPendingEventProcessing = true;
- ms_appInstance = wx_static_cast(wxAppConsole *, this);
+ ms_appInstance = static_cast<wxAppConsole *>(this);
#ifdef __WXDEBUG__
SetTraceMasks();
}
// ----------------------------------------------------------------------------
-// initilization/cleanup
+// initialization/cleanup
// ----------------------------------------------------------------------------
-bool wxAppConsoleBase::Initialize(int& argcOrig, wxChar **argvOrig)
+bool wxAppConsoleBase::Initialize(int& WXUNUSED(argc), wxChar **argv)
{
#if wxUSE_INTL
GetTraits()->SetLocale();
#endif // wxUSE_INTL
- // remember the command line arguments
- argc = argcOrig;
- argv = argvOrig;
-
-#if wxUSE_THREADS
- wxPendingEventsLocker = new wxCriticalSection;
-#endif
-
#ifndef __WXPALMOS__
- if ( m_appName.empty() && argv )
+ if ( m_appName.empty() && argv && argv[0] )
{
// the application name is, by default, the name of its executable file
wxFileName::SplitPath(argv[0], NULL, &m_appName, NULL);
delete m_mainLoop;
m_mainLoop = NULL;
}
-
- delete wxPendingEvents;
- wxPendingEvents = NULL;
-
-#if wxUSE_THREADS
- delete wxPendingEventsLocker;
- wxPendingEventsLocker = NULL;
-#endif // wxUSE_THREADS
}
// ----------------------------------------------------------------------------
#if wxUSE_CONFIG
// delete the config object if any (don't use Get() here, but Set()
// because Get() could create a new config object)
- delete wxConfigBase::Set((wxConfigBase *) NULL);
+ delete wxConfigBase::Set(NULL);
#endif // wxUSE_CONFIG
return 0;
return m_traits;
}
+/* static */
+wxAppTraits *wxAppConsoleBase::GetTraitsIfExists()
+{
+ wxAppConsole * const app = GetInstance();
+ return app ? app->GetTraits() : NULL;
+}
+
// ----------------------------------------------------------------------------
-// event processing
+// wxEventLoop redirection
// ----------------------------------------------------------------------------
int wxAppConsoleBase::MainLoop()
return loop && loop->Dispatch();
}
-bool wxAppConsoleBase::HasPendingEvents() const
+bool wxAppConsoleBase::Yield(bool onlyIfNeeded)
{
- // ensure that we're the only thread to modify the pending events list
- wxENTER_CRIT_SECT( *wxPendingEventsLocker );
+ wxEventLoopBase * const loop = wxEventLoopBase::GetActive();
- if ( !wxPendingEvents )
- {
- wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
- return false;
- }
- wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
- return true;
+ return loop && loop->Yield(onlyIfNeeded);
+}
+
+void wxAppConsoleBase::WakeUpIdle()
+{
+ if ( m_mainLoop )
+ m_mainLoop->WakeUp();
+}
+
+bool wxAppConsoleBase::ProcessIdle()
+{
+ wxEventLoopBase * const loop = wxEventLoopBase::GetActive();
+
+ return loop && loop->ProcessIdle();
}
+// ----------------------------------------------------------------------------
+// events
+// ----------------------------------------------------------------------------
+
/* static */
bool wxAppConsoleBase::IsMainLoopRunning()
{
return app && app->m_mainLoop != NULL;
}
-void wxAppConsoleBase::ProcessPendingEvents()
+int wxAppConsoleBase::FilterEvent(wxEvent& WXUNUSED(event))
{
-#if wxUSE_THREADS
- if ( !wxPendingEventsLocker )
- return;
-#endif
+ // process the events normally by default
+ return -1;
+}
- if ( !HasPendingEvents() )
- return;
+void wxAppConsoleBase::DelayPendingEventHandler(wxEvtHandler* toDelay)
+{
+ wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
- wxENTER_CRIT_SECT( *wxPendingEventsLocker );
+ // move the handler from the list of handlers with processable pending events
+ // to the list of handlers with pending events which needs to be processed later
+ m_handlersWithPendingEvents.Remove(toDelay);
- // iterate until the list becomes empty
- wxList::compatibility_iterator node = wxPendingEvents->GetFirst();
- while (node)
- {
- wxEvtHandler *handler = (wxEvtHandler *)node->GetData();
- wxPendingEvents->Erase(node);
+ if (m_handlersWithPendingDelayedEvents.Index(toDelay) == wxNOT_FOUND)
+ m_handlersWithPendingDelayedEvents.Add(toDelay);
- // In ProcessPendingEvents(), new handlers might be add
- // and we can safely leave the critical section here.
- wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
+ wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
+}
- handler->ProcessPendingEvents();
+void wxAppConsoleBase::RemovePendingEventHandler(wxEvtHandler* toRemove)
+{
+ wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
- wxENTER_CRIT_SECT( *wxPendingEventsLocker );
+ if (m_handlersWithPendingEvents.Index(toRemove) != wxNOT_FOUND)
+ {
+ m_handlersWithPendingEvents.Remove(toRemove);
- node = wxPendingEvents->GetFirst();
+ // check that the handler was present only once in the list
+ wxASSERT_MSG( m_handlersWithPendingEvents.Index(toRemove) == wxNOT_FOUND,
+ "Handler occurs twice in the m_handlersWithPendingEvents list!" );
}
+ //else: it wasn't in this list at all, it's ok
- wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
+ if (m_handlersWithPendingDelayedEvents.Index(toRemove) != wxNOT_FOUND)
+ {
+ m_handlersWithPendingDelayedEvents.Remove(toRemove);
+
+ // check that the handler was present only once in the list
+ wxASSERT_MSG( m_handlersWithPendingDelayedEvents.Index(toRemove) == wxNOT_FOUND,
+ "Handler occurs twice in m_handlersWithPendingDelayedEvents list!" );
+ }
+ //else: it wasn't in this list at all, it's ok
+
+ wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
}
-void wxAppConsoleBase::WakeUpIdle()
+void wxAppConsoleBase::AppendPendingEventHandler(wxEvtHandler* toAppend)
{
- if ( m_mainLoop )
- m_mainLoop->WakeUp();
+ wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
+
+ if ( m_handlersWithPendingEvents.Index(toAppend) == wxNOT_FOUND )
+ m_handlersWithPendingEvents.Add(toAppend);
+
+ wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
}
-bool wxAppConsoleBase::ProcessIdle()
+bool wxAppConsoleBase::HasPendingEvents() const
{
- wxIdleEvent event;
+ wxENTER_CRIT_SECT(const_cast<wxAppConsoleBase*>(this)->m_handlersWithPendingEventsLocker);
- event.SetEventObject(this);
- ProcessEvent(event);
- return event.MoreRequested();
+ bool has = !m_handlersWithPendingEvents.IsEmpty();
+
+ wxLEAVE_CRIT_SECT(const_cast<wxAppConsoleBase*>(this)->m_handlersWithPendingEventsLocker);
+
+ return has;
}
-int wxAppConsoleBase::FilterEvent(wxEvent& WXUNUSED(event))
+void wxAppConsoleBase::SuspendProcessingOfPendingEvents()
{
- // process the events normally by default
- return -1;
+ m_bDoPendingEventProcessing = false;
+}
+
+void wxAppConsoleBase::ResumeProcessingOfPendingEvents()
+{
+ m_bDoPendingEventProcessing = true;
+}
+
+void wxAppConsoleBase::ProcessPendingEvents()
+{
+ if (!m_bDoPendingEventProcessing)
+ return;
+
+ wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
+
+ wxCHECK_RET( m_handlersWithPendingDelayedEvents.IsEmpty(),
+ "this helper list should be empty" );
+
+ // iterate until the list becomes empty: the handlers remove themselves
+ // from it when they don't have any more pending events
+ while (!m_handlersWithPendingEvents.IsEmpty())
+ {
+ // In ProcessPendingEvents(), new handlers might be added
+ // and we can safely leave the critical section here.
+ wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
+
+ // NOTE: we always call ProcessPendingEvents() on the first event handler
+ // with pending events because handlers auto-remove themselves
+ // from this list (see RemovePendingEventHandler) if they have no
+ // more pending events.
+ m_handlersWithPendingEvents[0]->ProcessPendingEvents();
+
+ wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
+ }
+
+ // now the wxHandlersWithPendingEvents is surely empty; however some event
+ // handlers may have moved themselves into wxHandlersWithPendingDelayedEvents
+ // because of a selective wxYield call in progress.
+ // Now we need to move them back to wxHandlersWithPendingEvents so the next
+ // call to this function has the chance of processing them:
+ if (!m_handlersWithPendingDelayedEvents.IsEmpty())
+ {
+ WX_APPEND_ARRAY(m_handlersWithPendingEvents, m_handlersWithPendingDelayedEvents);
+ m_handlersWithPendingDelayedEvents.Clear();
+ }
+
+ wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
+}
+
+void wxAppConsoleBase::DeletePendingEvents()
+{
+ wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
+
+ wxCHECK_RET( m_handlersWithPendingDelayedEvents.IsEmpty(),
+ "this helper list should be empty" );
+
+ for (unsigned int i=0; i<m_handlersWithPendingEvents.GetCount(); i++)
+ m_handlersWithPendingEvents[i]->DeletePendingEvents();
+
+ m_handlersWithPendingEvents.Clear();
+
+ wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
}
// ----------------------------------------------------------------------------
(handler->*func)(event);
}
+void wxAppConsoleBase::CallEventHandler(wxEvtHandler *handler,
+ wxEventFunctor& functor,
+ wxEvent& event) const
+{
+ // If the functor holds a method then, for backward compatibility, call
+ // HandleEvent():
+ wxEventFunction eventFunction = functor.GetEvtMethod();
+
+ if ( eventFunction )
+ HandleEvent(handler, eventFunction, event);
+ else
+ functor(handler, event);
+}
+
void wxAppConsoleBase::OnUnhandledException()
{
#ifdef __WXDEBUG__
#if wxUSE_CMDLINE_PARSER
-#define OPTION_VERBOSE _T("verbose")
+#define OPTION_VERBOSE "verbose"
void wxAppConsoleBase::OnInitCmdLine(wxCmdLineParser& parser)
{
{
{
wxCMD_LINE_SWITCH,
- _T("h"),
- _T("help"),
+ "h",
+ "help",
gettext_noop("show this help message"),
wxCMD_LINE_VAL_NONE,
wxCMD_LINE_OPTION_HELP
#if wxUSE_LOG
{
wxCMD_LINE_SWITCH,
- wxEmptyString,
+ NULL,
OPTION_VERBOSE,
gettext_noop("generate verbose log messages"),
wxCMD_LINE_VAL_NONE,
#endif // wxUSE_LOG
// terminator
- {
- wxCMD_LINE_NONE,
- wxEmptyString,
- wxEmptyString,
- wxEmptyString,
- wxCMD_LINE_VAL_NONE,
- 0x0
- }
+ wxCMD_LINE_DESC_END
};
parser.SetDesc(cmdLineDesc);
// normally wxLogFatalError doesn't return
return false;
}
-#undef wxCMP
return true;
}
-#ifdef __WXDEBUG__
-
void wxAppConsoleBase::OnAssertFailure(const wxChar *file,
int line,
const wxChar *func,
const wxChar *cond,
const wxChar *msg)
{
+#if wxDEBUG_LEVEL
ShowAssertDialog(file, line, func, cond, msg, GetTraits());
+#else
+ // this function is still present even in debug level 0 build for ABI
+ // compatibility reasons but is never called there and so can simply do
+ // nothing in it
+ wxUnusedVar(file);
+ wxUnusedVar(line);
+ wxUnusedVar(func);
+ wxUnusedVar(cond);
+ wxUnusedVar(msg);
+#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL
}
void wxAppConsoleBase::OnAssert(const wxChar *file,
OnAssertFailure(file, line, NULL, cond, msg);
}
-#endif // __WXDEBUG__
-
// ============================================================================
// other classes implementations
// ============================================================================
return NULL;
}
-#ifdef __WXDEBUG__
bool wxConsoleAppTraitsBase::ShowAssertDialog(const wxString& msg)
{
return wxAppTraitsBase::ShowAssertDialog(msg);
}
-#endif
bool wxConsoleAppTraitsBase::HasStderr()
{
// nothing to do
}
-#if wxUSE_SOCKETS
-GSocketGUIFunctionsTable* wxConsoleAppTraitsBase::GetSocketGUIFunctionsTable()
-{
- return NULL;
-}
-#endif
-
// ----------------------------------------------------------------------------
// wxAppTraits
// ----------------------------------------------------------------------------
#if wxUSE_INTL
void wxAppTraitsBase::SetLocale()
{
- setlocale(LC_ALL, "");
+ wxSetlocale(LC_ALL, "");
wxUpdateLocaleIsUtf8();
}
#endif
-#ifdef __WXDEBUG__
+#if wxUSE_THREADS
+void wxMutexGuiEnterImpl();
+void wxMutexGuiLeaveImpl();
+
+void wxAppTraitsBase::MutexGuiEnter()
+{
+ wxMutexGuiEnterImpl();
+}
+
+void wxAppTraitsBase::MutexGuiLeave()
+{
+ wxMutexGuiLeaveImpl();
+}
+
+void WXDLLIMPEXP_BASE wxMutexGuiEnter()
+{
+ wxAppTraits * const traits = wxAppConsoleBase::GetTraitsIfExists();
+ if ( traits )
+ traits->MutexGuiEnter();
+}
+
+void WXDLLIMPEXP_BASE wxMutexGuiLeave()
+{
+ wxAppTraits * const traits = wxAppConsoleBase::GetTraitsIfExists();
+ if ( traits )
+ traits->MutexGuiLeave();
+}
+#endif // wxUSE_THREADS
bool wxAppTraitsBase::ShowAssertDialog(const wxString& msgOriginal)
{
+#if wxDEBUG_LEVEL
wxString msg = msgOriginal;
#if wxUSE_STACKWALKER
#endif // wxUSE_STACKWALKER
return DoShowAssertDialog(msg);
+#else // !wxDEBUG_LEVEL
+ wxUnusedVar(msgOriginal);
+
+ return false;
+#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL
}
#if wxUSE_STACKWALKER
wxString wxAppTraitsBase::GetAssertStackTrace()
{
+#if wxDEBUG_LEVEL
wxString stackTrace;
class StackDump : public wxStackWalker
stackTrace = stackTrace.BeforeLast(wxT('\n'));
return stackTrace;
+#else // !wxDEBUG_LEVEL
+ // this function is still present for ABI-compatibility even in debug level
+ // 0 build but is not used there and so can simply do nothing
+ return wxString();
+#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL
}
#endif // wxUSE_STACKWALKER
-#endif // __WXDEBUG__
-
// ============================================================================
// global functions implementation
// ============================================================================
//else: do nothing, what can we do?
}
-#ifdef __WXDEBUG__
-
// wxASSERT() helper
bool wxAssertIsEqual(int x, int y)
{
return x == y;
}
+#if wxDEBUG_LEVEL
+
// break into the debugger
void wxTrap()
{
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
DebugBreak();
-#elif defined(__WXMAC__) && !defined(__DARWIN__)
- #if __powerc
- Debugger();
- #else
- SysBreak();
- #endif
#elif defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
Debugger();
#elif defined(__UNIX__)
#endif // Win/Unix
}
-// this function is called when an assert fails
-static void wxDoOnAssert(const wxString& szFile,
- int nLine,
- const wxString& szFunc,
- const wxString& szCond,
- const wxString& szMsg = wxEmptyString)
+// default assert handler
+static void
+wxDefaultAssertHandler(const wxString& file,
+ int line,
+ const wxString& func,
+ const wxString& cond,
+ const wxString& msg)
{
// FIXME MT-unsafe
- static bool s_bInAssert = false;
+ static int s_bInAssert = 0;
- if ( s_bInAssert )
+ wxRecursionGuard guard(s_bInAssert);
+ if ( guard.IsInside() )
{
- // He-e-e-e-elp!! we're trapped in endless loop
+ // can't use assert here to avoid infinite loops, so just trap
wxTrap();
- s_bInAssert = false;
-
return;
}
- s_bInAssert = true;
-
if ( !wxTheApp )
{
// by default, show the assert dialog box -- we can't customize this
// behaviour
- ShowAssertDialog(szFile, nLine, szFunc, szCond, szMsg);
+ ShowAssertDialog(file, line, func, cond, msg);
}
else
{
// let the app process it as it wants
// FIXME-UTF8: use wc_str(), not c_str(), when ANSI build is removed
- wxTheApp->OnAssertFailure(szFile.c_str(), nLine, szFunc.c_str(),
- szCond.c_str(), szMsg.c_str());
+ wxTheApp->OnAssertFailure(file.c_str(), line, func.c_str(),
+ cond.c_str(), msg.c_str());
}
-
- s_bInAssert = false;
}
-void wxOnAssert(const wxString& szFile,
- int nLine,
- const wxString& szFunc,
- const wxString& szCond,
- const wxString& szMsg)
+wxAssertHandler_t wxTheAssertHandler = wxDefaultAssertHandler;
+
+void wxOnAssert(const wxString& file,
+ int line,
+ const wxString& func,
+ const wxString& cond,
+ const wxString& msg)
{
- wxDoOnAssert(szFile, nLine, szFunc, szCond, szMsg);
+ wxTheAssertHandler(file, line, func, cond, msg);
}
-void wxOnAssert(const wxString& szFile,
- int nLine,
- const wxString& szFunc,
- const wxString& szCond)
+void wxOnAssert(const wxString& file,
+ int line,
+ const wxString& func,
+ const wxString& cond)
{
- wxDoOnAssert(szFile, nLine, szFunc, szCond);
+ wxTheAssertHandler(file, line, func, cond, wxString());
}
-void wxOnAssert(const wxChar *szFile,
- int nLine,
- const char *szFunc,
- const wxChar *szCond,
- const wxChar *szMsg)
+void wxOnAssert(const wxChar *file,
+ int line,
+ const char *func,
+ const wxChar *cond,
+ const wxChar *msg)
{
- wxDoOnAssert(szFile, nLine, szFunc, szCond, szMsg);
+ // this is the backwards-compatible version (unless we don't use Unicode)
+ // so it could be called directly from the user code and this might happen
+ // even when wxTheAssertHandler is NULL
+#if wxUSE_UNICODE
+ if ( wxTheAssertHandler )
+#endif // wxUSE_UNICODE
+ wxTheAssertHandler(file, line, func, cond, msg);
}
-void wxOnAssert(const char *szFile,
- int nLine,
- const char *szFunc,
- const char *szCond,
- const wxString& szMsg)
+void wxOnAssert(const char *file,
+ int line,
+ const char *func,
+ const char *cond,
+ const wxString& msg)
{
- wxDoOnAssert(szFile, nLine, szFunc, szCond, szMsg);
+ wxTheAssertHandler(file, line, func, cond, msg);
}
-void wxOnAssert(const char *szFile,
- int nLine,
- const char *szFunc,
- const char *szCond,
+void wxOnAssert(const char *file,
+ int line,
+ const char *func,
+ const char *cond,
const wxCStrData& msg)
{
- wxDoOnAssert(szFile, nLine, szFunc, szCond, msg);
+ wxTheAssertHandler(file, line, func, cond, msg);
}
#if wxUSE_UNICODE
-void wxOnAssert(const char *szFile,
- int nLine,
- const char *szFunc,
- const char *szCond)
+void wxOnAssert(const char *file,
+ int line,
+ const char *func,
+ const char *cond)
{
- wxDoOnAssert(szFile, nLine, szFunc, szCond);
+ wxTheAssertHandler(file, line, func, cond, wxString());
}
-void wxOnAssert(const char *szFile,
- int nLine,
- const char *szFunc,
- const char *szCond,
- const char *szMsg)
+void wxOnAssert(const char *file,
+ int line,
+ const char *func,
+ const char *cond,
+ const char *msg)
{
- wxDoOnAssert(szFile, nLine, szFunc, szCond, szMsg);
+ wxTheAssertHandler(file, line, func, cond, msg);
}
-void wxOnAssert(const char *szFile,
- int nLine,
- const char *szFunc,
- const char *szCond,
- const wxChar *szMsg)
+void wxOnAssert(const char *file,
+ int line,
+ const char *func,
+ const char *cond,
+ const wxChar *msg)
{
- wxDoOnAssert(szFile, nLine, szFunc, szCond, szMsg);
+ wxTheAssertHandler(file, line, func, cond, msg);
}
#endif // wxUSE_UNICODE
-#endif // __WXDEBUG__
+#endif // wxDEBUG_LEVEL
// ============================================================================
// private functions implementation
#endif // wxUSE_LOG
}
+#endif // __WXDEBUG__
+
+#if wxDEBUG_LEVEL
+
+static
bool DoShowAssertDialog(const wxString& msg)
{
// under MSW we can show the dialog even in the console mode
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
wxString msgDlg(msg);
- // this message is intentionally not translated -- it is for
- // developpers only
+ // this message is intentionally not translated -- it is for developers
+ // only -- and the less code we use here, less is the danger of recursively
+ // asserting and dying
msgDlg += wxT("\nDo you want to stop the program?\n")
wxT("You can also choose [Cancel] to suppress ")
wxT("further warnings.");
return false;
}
-// show the assert modal dialog
+// show the standard assert dialog
static
-void ShowAssertDialog(const wxString& szFile,
- int nLine,
- const wxString& szFunc,
- const wxString& szCond,
- const wxString& szMsg,
+void ShowAssertDialog(const wxString& file,
+ int line,
+ const wxString& func,
+ const wxString& cond,
+ const wxString& msgUser,
wxAppTraits *traits)
{
// this variable can be set to true to suppress "assert failure" messages
// 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);
+ msg.Printf(wxT("%s(%d): assert \"%s\" failed"), file, line, cond);
// add the function name, if any
- if ( !szFunc.empty() )
- msg << _T(" in ") << szFunc << _T("()");
+ if ( !func.empty() )
+ msg << _T(" in ") << func << _T("()");
// and the message itself
- if ( !szMsg.empty() )
+ if ( !msgUser.empty() )
{
- msg << _T(": ") << szMsg;
+ msg << _T(": ") << msgUser;
}
else // no message given
{
}
}
-#endif // __WXDEBUG__
+#endif // wxDEBUG_LEVEL