]> git.saurik.com Git - wxWidgets.git/blob - src/common/appbase.cpp
Minor cleanup.
[wxWidgets.git] / src / common / appbase.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/appbase.cpp
3 // Purpose: implements wxAppConsole class
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 19.06.2003 (extracted from common/appcmn.cpp)
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // License: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #ifndef WX_PRECOMP
28 #ifdef __WXMSW__
29 #include "wx/msw/wrapwin.h" // includes windows.h for MessageBox()
30 #endif
31 #include "wx/list.h"
32 #include "wx/app.h"
33 #include "wx/intl.h"
34 #include "wx/log.h"
35 #include "wx/utils.h"
36 #endif //WX_PRECOMP
37
38 #include "wx/apptrait.h"
39 #include "wx/cmdline.h"
40 #include "wx/confbase.h"
41 #include "wx/filename.h"
42 #include "wx/msgout.h"
43 #include "wx/tokenzr.h"
44
45 #if !defined(__WXMSW__) || defined(__WXMICROWIN__)
46 #include <signal.h> // for SIGTRAP used by wxTrap()
47 #endif //Win/Unix
48
49 #if wxUSE_FONTMAP
50 #include "wx/fontmap.h"
51 #endif // wxUSE_FONTMAP
52
53 #if defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
54 // For MacTypes.h for Debugger function
55 #include <CoreFoundation/CFBase.h>
56 #endif
57
58 #if defined(__WXMAC__)
59 #ifdef __DARWIN__
60 #include <CoreServices/CoreServices.h>
61 #else
62 #include "wx/mac/private.h" // includes mac headers
63 #endif
64 #endif // __WXMAC__
65
66 #ifdef __WXDEBUG__
67 #if wxUSE_STACKWALKER
68 #include "wx/stackwalk.h"
69 #ifdef __WXMSW__
70 #include "wx/msw/debughlp.h"
71 #endif
72 #endif // wxUSE_STACKWALKER
73 #endif // __WXDEBUG__
74
75 // wxABI_VERSION can be defined when compiling applications but it should be
76 // left undefined when compiling the library itself, it is then set to its
77 // default value in version.h
78 #if wxABI_VERSION != wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + 99
79 #error "wxABI_VERSION should not be defined when compiling the library"
80 #endif
81
82 // ----------------------------------------------------------------------------
83 // private functions prototypes
84 // ----------------------------------------------------------------------------
85
86 #ifdef __WXDEBUG__
87 // really just show the assert dialog
88 static bool DoShowAssertDialog(const wxString& msg);
89
90 // prepare for showing the assert dialog, use the given traits or
91 // DoShowAssertDialog() as last fallback to really show it
92 static
93 void ShowAssertDialog(const wxChar *szFile,
94 int nLine,
95 const wxChar *szFunc,
96 const wxChar *szCond,
97 const wxChar *szMsg,
98 wxAppTraits *traits = NULL);
99
100 // turn on the trace masks specified in the env variable WXTRACE
101 static void LINKAGEMODE SetTraceMasks();
102 #endif // __WXDEBUG__
103
104 // ----------------------------------------------------------------------------
105 // global vars
106 // ----------------------------------------------------------------------------
107
108 wxAppConsole *wxAppConsole::ms_appInstance = NULL;
109
110 wxAppInitializerFunction wxAppConsole::ms_appInitFn = NULL;
111
112 // ============================================================================
113 // wxAppConsole implementation
114 // ============================================================================
115
116 // ----------------------------------------------------------------------------
117 // ctor/dtor
118 // ----------------------------------------------------------------------------
119
120 wxAppConsole::wxAppConsole()
121 {
122 m_traits = NULL;
123
124 ms_appInstance = this;
125
126 #ifdef __WXDEBUG__
127 SetTraceMasks();
128 #if wxUSE_UNICODE
129 // In unicode mode the SetTraceMasks call can cause an apptraits to be
130 // created, but since we are still in the constructor the wrong kind will
131 // be created for GUI apps. Destroy it so it can be created again later.
132 delete m_traits;
133 m_traits = NULL;
134 #endif
135 #endif
136 }
137
138 wxAppConsole::~wxAppConsole()
139 {
140 delete m_traits;
141 }
142
143 // ----------------------------------------------------------------------------
144 // initilization/cleanup
145 // ----------------------------------------------------------------------------
146
147 bool wxAppConsole::Initialize(int& argcOrig, wxChar **argvOrig)
148 {
149 // remember the command line arguments
150 argc = argcOrig;
151 argv = argvOrig;
152
153 #ifndef __WXPALMOS__
154 if ( m_appName.empty() && argv )
155 {
156 // the application name is, by default, the name of its executable file
157 wxFileName::SplitPath(argv[0], NULL, &m_appName, NULL);
158 }
159 #endif
160
161 return true;
162 }
163
164 void wxAppConsole::CleanUp()
165 {
166 }
167
168 // ----------------------------------------------------------------------------
169 // OnXXX() callbacks
170 // ----------------------------------------------------------------------------
171
172 bool wxAppConsole::OnInit()
173 {
174 #if wxUSE_CMDLINE_PARSER
175 wxCmdLineParser parser(argc, argv);
176
177 OnInitCmdLine(parser);
178
179 bool cont;
180 switch ( parser.Parse(false /* don't show usage */) )
181 {
182 case -1:
183 cont = OnCmdLineHelp(parser);
184 break;
185
186 case 0:
187 cont = OnCmdLineParsed(parser);
188 break;
189
190 default:
191 cont = OnCmdLineError(parser);
192 break;
193 }
194
195 if ( !cont )
196 return false;
197 #endif // wxUSE_CMDLINE_PARSER
198
199 return true;
200 }
201
202 int wxAppConsole::OnExit()
203 {
204 #if wxUSE_CONFIG
205 // delete the config object if any (don't use Get() here, but Set()
206 // because Get() could create a new config object)
207 delete wxConfigBase::Set((wxConfigBase *) NULL);
208 #endif // wxUSE_CONFIG
209
210 return 0;
211 }
212
213 void wxAppConsole::Exit()
214 {
215 exit(-1);
216 }
217
218 wxLayoutDirection wxAppConsole::GetLayoutDirection() const
219 {
220 #if wxUSE_INTL
221 const wxLocale *const locale = wxGetLocale();
222 if ( locale )
223 {
224 const wxLanguageInfo *const
225 info = wxLocale::GetLanguageInfo(locale->GetLanguage());
226
227 if ( info )
228 return info->LayoutDirection;
229 }
230 #endif // wxUSE_INTL
231
232 // we don't know
233 return wxLayout_Default;
234 }
235
236 // ----------------------------------------------------------------------------
237 // traits stuff
238 // ----------------------------------------------------------------------------
239
240 wxAppTraits *wxAppConsole::CreateTraits()
241 {
242 return new wxConsoleAppTraits;
243 }
244
245 wxAppTraits *wxAppConsole::GetTraits()
246 {
247 // FIXME-MT: protect this with a CS?
248 if ( !m_traits )
249 {
250 m_traits = CreateTraits();
251
252 wxASSERT_MSG( m_traits, _T("wxApp::CreateTraits() failed?") );
253 }
254
255 return m_traits;
256 }
257
258 // we must implement CreateXXX() in wxApp itself for backwards compatibility
259 #if WXWIN_COMPATIBILITY_2_4
260
261 #if wxUSE_LOG
262
263 wxLog *wxAppConsole::CreateLogTarget()
264 {
265 wxAppTraits *traits = GetTraits();
266 return traits ? traits->CreateLogTarget() : NULL;
267 }
268
269 #endif // wxUSE_LOG
270
271 wxMessageOutput *wxAppConsole::CreateMessageOutput()
272 {
273 wxAppTraits *traits = GetTraits();
274 return traits ? traits->CreateMessageOutput() : NULL;
275 }
276
277 #endif // WXWIN_COMPATIBILITY_2_4
278
279 // ----------------------------------------------------------------------------
280 // event processing
281 // ----------------------------------------------------------------------------
282
283 void wxAppConsole::ProcessPendingEvents()
284 {
285 #if wxUSE_THREADS
286 if ( !wxPendingEventsLocker )
287 return;
288 #endif
289
290 // ensure that we're the only thread to modify the pending events list
291 wxENTER_CRIT_SECT( *wxPendingEventsLocker );
292
293 if ( !wxPendingEvents )
294 {
295 wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
296 return;
297 }
298
299 // iterate until the list becomes empty
300 wxList::compatibility_iterator node = wxPendingEvents->GetFirst();
301 while (node)
302 {
303 wxEvtHandler *handler = (wxEvtHandler *)node->GetData();
304 wxPendingEvents->Erase(node);
305
306 // In ProcessPendingEvents(), new handlers might be add
307 // and we can safely leave the critical section here.
308 wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
309
310 handler->ProcessPendingEvents();
311
312 wxENTER_CRIT_SECT( *wxPendingEventsLocker );
313
314 node = wxPendingEvents->GetFirst();
315 }
316
317 wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
318 }
319
320 int wxAppConsole::FilterEvent(wxEvent& WXUNUSED(event))
321 {
322 // process the events normally by default
323 return -1;
324 }
325
326 // ----------------------------------------------------------------------------
327 // exception handling
328 // ----------------------------------------------------------------------------
329
330 #if wxUSE_EXCEPTIONS
331
332 void
333 wxAppConsole::HandleEvent(wxEvtHandler *handler,
334 wxEventFunction func,
335 wxEvent& event) const
336 {
337 // by default, simply call the handler
338 (handler->*func)(event);
339 }
340
341 #endif // wxUSE_EXCEPTIONS
342
343 // ----------------------------------------------------------------------------
344 // cmd line parsing
345 // ----------------------------------------------------------------------------
346
347 #if wxUSE_CMDLINE_PARSER
348
349 #define OPTION_VERBOSE _T("verbose")
350
351 void wxAppConsole::OnInitCmdLine(wxCmdLineParser& parser)
352 {
353 // the standard command line options
354 static const wxCmdLineEntryDesc cmdLineDesc[] =
355 {
356 {
357 wxCMD_LINE_SWITCH,
358 _T("h"),
359 _T("help"),
360 gettext_noop("show this help message"),
361 wxCMD_LINE_VAL_NONE,
362 wxCMD_LINE_OPTION_HELP
363 },
364
365 #if wxUSE_LOG
366 {
367 wxCMD_LINE_SWITCH,
368 wxEmptyString,
369 OPTION_VERBOSE,
370 gettext_noop("generate verbose log messages"),
371 wxCMD_LINE_VAL_NONE,
372 0x0
373 },
374 #endif // wxUSE_LOG
375
376 // terminator
377 {
378 wxCMD_LINE_NONE,
379 wxEmptyString,
380 wxEmptyString,
381 wxEmptyString,
382 wxCMD_LINE_VAL_NONE,
383 0x0
384 }
385 };
386
387 parser.SetDesc(cmdLineDesc);
388 }
389
390 bool wxAppConsole::OnCmdLineParsed(wxCmdLineParser& parser)
391 {
392 #if wxUSE_LOG
393 if ( parser.Found(OPTION_VERBOSE) )
394 {
395 wxLog::SetVerbose(true);
396 }
397 #else
398 wxUnusedVar(parser);
399 #endif // wxUSE_LOG
400
401 return true;
402 }
403
404 bool wxAppConsole::OnCmdLineHelp(wxCmdLineParser& parser)
405 {
406 parser.Usage();
407
408 return false;
409 }
410
411 bool wxAppConsole::OnCmdLineError(wxCmdLineParser& parser)
412 {
413 parser.Usage();
414
415 return false;
416 }
417
418 #endif // wxUSE_CMDLINE_PARSER
419
420 // ----------------------------------------------------------------------------
421 // debugging support
422 // ----------------------------------------------------------------------------
423
424 /* static */
425 bool wxAppConsole::CheckBuildOptions(const char *optionsSignature,
426 const char *componentName)
427 {
428 #if 0 // can't use wxLogTrace, not up and running yet
429 printf("checking build options object '%s' (ptr %p) in '%s'\n",
430 optionsSignature, optionsSignature, componentName);
431 #endif
432
433 if ( strcmp(optionsSignature, WX_BUILD_OPTIONS_SIGNATURE) != 0 )
434 {
435 wxString lib = wxString::FromAscii(WX_BUILD_OPTIONS_SIGNATURE);
436 wxString prog = wxString::FromAscii(optionsSignature);
437 wxString progName = wxString::FromAscii(componentName);
438 wxString msg;
439
440 msg.Printf(_T("Mismatch between the program and library build versions detected.\nThe library used %s,\nand %s used %s."),
441 lib.c_str(), progName.c_str(), prog.c_str());
442
443 wxLogFatalError(msg.c_str());
444
445 // normally wxLogFatalError doesn't return
446 return false;
447 }
448 #undef wxCMP
449
450 return true;
451 }
452
453 #ifdef __WXDEBUG__
454
455 void wxAppConsole::OnAssertFailure(const wxChar *file,
456 int line,
457 const wxChar *func,
458 const wxChar *cond,
459 const wxChar *msg)
460 {
461 ShowAssertDialog(file, line, func, cond, msg, GetTraits());
462 }
463
464 void wxAppConsole::OnAssert(const wxChar *file,
465 int line,
466 const wxChar *cond,
467 const wxChar *msg)
468 {
469 OnAssertFailure(file, line, NULL, cond, msg);
470 }
471
472 #endif // __WXDEBUG__
473
474 #if WXWIN_COMPATIBILITY_2_4
475
476 bool wxAppConsole::CheckBuildOptions(const wxBuildOptions& buildOptions)
477 {
478 return CheckBuildOptions(buildOptions.m_signature, "your program");
479 }
480
481 #endif
482
483 // ============================================================================
484 // other classes implementations
485 // ============================================================================
486
487 // ----------------------------------------------------------------------------
488 // wxConsoleAppTraitsBase
489 // ----------------------------------------------------------------------------
490
491 #if wxUSE_LOG
492
493 wxLog *wxConsoleAppTraitsBase::CreateLogTarget()
494 {
495 return new wxLogStderr;
496 }
497
498 #endif // wxUSE_LOG
499
500 wxMessageOutput *wxConsoleAppTraitsBase::CreateMessageOutput()
501 {
502 return new wxMessageOutputStderr;
503 }
504
505 #if wxUSE_FONTMAP
506
507 wxFontMapper *wxConsoleAppTraitsBase::CreateFontMapper()
508 {
509 return (wxFontMapper *)new wxFontMapperBase;
510 }
511
512 #endif // wxUSE_FONTMAP
513
514 wxRendererNative *wxConsoleAppTraitsBase::CreateRenderer()
515 {
516 // console applications don't use renderers
517 return NULL;
518 }
519
520 #ifdef __WXDEBUG__
521 bool wxConsoleAppTraitsBase::ShowAssertDialog(const wxString& msg)
522 {
523 return wxAppTraitsBase::ShowAssertDialog(msg);
524 }
525 #endif
526
527 bool wxConsoleAppTraitsBase::HasStderr()
528 {
529 // console applications always have stderr, even under Mac/Windows
530 return true;
531 }
532
533 void wxConsoleAppTraitsBase::ScheduleForDestroy(wxObject *object)
534 {
535 delete object;
536 }
537
538 void wxConsoleAppTraitsBase::RemoveFromPendingDelete(wxObject * WXUNUSED(object))
539 {
540 // nothing to do
541 }
542
543 #if wxUSE_SOCKETS
544 GSocketGUIFunctionsTable* wxConsoleAppTraitsBase::GetSocketGUIFunctionsTable()
545 {
546 return NULL;
547 }
548 #endif
549
550 // ----------------------------------------------------------------------------
551 // wxAppTraits
552 // ----------------------------------------------------------------------------
553
554 #ifdef __WXDEBUG__
555
556 bool wxAppTraitsBase::ShowAssertDialog(const wxString& msg)
557 {
558 return DoShowAssertDialog(msg);
559 }
560
561 #endif // __WXDEBUG__
562
563 // ============================================================================
564 // global functions implementation
565 // ============================================================================
566
567 void wxExit()
568 {
569 if ( wxTheApp )
570 {
571 wxTheApp->Exit();
572 }
573 else
574 {
575 // what else can we do?
576 exit(-1);
577 }
578 }
579
580 void wxWakeUpIdle()
581 {
582 if ( wxTheApp )
583 {
584 wxTheApp->WakeUpIdle();
585 }
586 //else: do nothing, what can we do?
587 }
588
589 #ifdef __WXDEBUG__
590
591 // wxASSERT() helper
592 bool wxAssertIsEqual(int x, int y)
593 {
594 return x == y;
595 }
596
597 // break into the debugger
598 void wxTrap()
599 {
600 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
601 DebugBreak();
602 #elif defined(__WXMAC__) && !defined(__DARWIN__)
603 #if __powerc
604 Debugger();
605 #else
606 SysBreak();
607 #endif
608 #elif defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
609 Debugger();
610 #elif defined(__UNIX__)
611 raise(SIGTRAP);
612 #else
613 // TODO
614 #endif // Win/Unix
615 }
616
617 // this function is called when an assert fails
618 void wxOnAssert(const wxChar *szFile,
619 int nLine,
620 const char *szFunc,
621 const wxChar *szCond,
622 const wxChar *szMsg)
623 {
624 // FIXME MT-unsafe
625 static bool s_bInAssert = false;
626
627 if ( s_bInAssert )
628 {
629 // He-e-e-e-elp!! we're trapped in endless loop
630 wxTrap();
631
632 s_bInAssert = false;
633
634 return;
635 }
636
637 s_bInAssert = true;
638
639 // __FUNCTION__ is always in ASCII, convert it to wide char if needed
640 const wxString strFunc = wxString::FromAscii(szFunc);
641
642 if ( !wxTheApp )
643 {
644 // by default, show the assert dialog box -- we can't customize this
645 // behaviour
646 ShowAssertDialog(szFile, nLine, strFunc, szCond, szMsg);
647 }
648 else
649 {
650 // let the app process it as it wants
651 wxTheApp->OnAssertFailure(szFile, nLine, strFunc, szCond, szMsg);
652 }
653
654 s_bInAssert = false;
655 }
656
657 #endif // __WXDEBUG__
658
659 // ============================================================================
660 // private functions implementation
661 // ============================================================================
662
663 #ifdef __WXDEBUG__
664
665 static void LINKAGEMODE SetTraceMasks()
666 {
667 #if wxUSE_LOG
668 wxString mask;
669 if ( wxGetEnv(wxT("WXTRACE"), &mask) )
670 {
671 wxStringTokenizer tkn(mask, wxT(",;:"));
672 while ( tkn.HasMoreTokens() )
673 wxLog::AddTraceMask(tkn.GetNextToken());
674 }
675 #endif // wxUSE_LOG
676 }
677
678 bool DoShowAssertDialog(const wxString& msg)
679 {
680 // under MSW we can show the dialog even in the console mode
681 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
682 wxString msgDlg(msg);
683
684 // this message is intentionally not translated -- it is for
685 // developpers only
686 msgDlg += wxT("\nDo you want to stop the program?\n")
687 wxT("You can also choose [Cancel] to suppress ")
688 wxT("further warnings.");
689
690 switch ( ::MessageBox(NULL, msgDlg, _T("wxWidgets Debug Alert"),
691 MB_YESNOCANCEL | MB_ICONSTOP ) )
692 {
693 case IDYES:
694 wxTrap();
695 break;
696
697 case IDCANCEL:
698 // stop the asserts
699 return true;
700
701 //case IDNO: nothing to do
702 }
703 #else // !__WXMSW__
704 wxFprintf(stderr, wxT("%s\n"), msg.c_str());
705 fflush(stderr);
706
707 // TODO: ask the user to enter "Y" or "N" on the console?
708 wxTrap();
709 #endif // __WXMSW__/!__WXMSW__
710
711 // continue with the asserts
712 return false;
713 }
714
715 #if wxUSE_STACKWALKER
716 static wxString GetAssertStackTrace()
717 {
718 wxString stackTrace;
719
720 class StackDump : public wxStackWalker
721 {
722 public:
723 StackDump() { }
724
725 const wxString& GetStackTrace() const { return m_stackTrace; }
726
727 protected:
728 virtual void OnStackFrame(const wxStackFrame& frame)
729 {
730 m_stackTrace << wxString::Format
731 (
732 _T("[%02d] "),
733 wx_truncate_cast(int, frame.GetLevel())
734 );
735
736 wxString name = frame.GetName();
737 if ( !name.empty() )
738 {
739 m_stackTrace << wxString::Format(_T("%-40s"), name.c_str());
740 }
741 else
742 {
743 m_stackTrace << wxString::Format(_T("%p"), frame.GetAddress());
744 }
745
746 if ( frame.HasSourceLocation() )
747 {
748 m_stackTrace << _T('\t')
749 << frame.GetFileName()
750 << _T(':')
751 << frame.GetLine();
752 }
753
754 m_stackTrace << _T('\n');
755 }
756
757 private:
758 wxString m_stackTrace;
759 };
760
761 StackDump dump;
762 dump.Walk(2); // don't show OnAssert() call itself
763 stackTrace = dump.GetStackTrace();
764
765 // don't show more than maxLines or we could get a dialog too tall to be
766 // shown on screen: 20 should be ok everywhere as even with 15 pixel high
767 // characters it is still only 300 pixels...
768 static const int maxLines = 20;
769 const int count = stackTrace.Freq(wxT('\n'));
770 for ( int i = 0; i < count - maxLines; i++ )
771 stackTrace = stackTrace.BeforeLast(wxT('\n'));
772
773 return stackTrace;
774 }
775 #endif // wxUSE_STACKWALKER
776
777 // show the assert modal dialog
778 static
779 void ShowAssertDialog(const wxChar *szFile,
780 int nLine,
781 const wxChar *szFunc,
782 const wxChar *szCond,
783 const wxChar *szMsg,
784 wxAppTraits *traits)
785 {
786 // this variable can be set to true to suppress "assert failure" messages
787 static bool s_bNoAsserts = false;
788
789 wxString msg;
790 msg.reserve(2048);
791
792 // make life easier for people using VC++ IDE by using this format: like
793 // this, clicking on the message will take us immediately to the place of
794 // the failed assert
795 msg.Printf(wxT("%s(%d): assert \"%s\" failed"), szFile, nLine, szCond);
796
797 // add the function name, if any
798 if ( szFunc && *szFunc )
799 msg << _T(" in ") << szFunc << _T("()");
800
801 // and the message itself
802 if ( szMsg )
803 {
804 msg << _T(": ") << szMsg;
805 }
806 else // no message given
807 {
808 msg << _T('.');
809 }
810
811 #if wxUSE_STACKWALKER
812 const wxString stackTrace = GetAssertStackTrace();
813 if ( !stackTrace.empty() )
814 {
815 msg << _T("\n\nCall stack:\n") << stackTrace;
816 }
817 #endif // wxUSE_STACKWALKER
818
819 #if wxUSE_THREADS
820 // if we are not in the main thread, output the assert directly and trap
821 // since dialogs cannot be displayed
822 if ( !wxThread::IsMain() )
823 {
824 msg += wxT(" [in child thread]");
825
826 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
827 msg << wxT("\r\n");
828 OutputDebugString(msg );
829 #else
830 // send to stderr
831 wxFprintf(stderr, wxT("%s\n"), msg.c_str());
832 fflush(stderr);
833 #endif
834 // He-e-e-e-elp!! we're asserting in a child thread
835 wxTrap();
836 }
837 else
838 #endif // wxUSE_THREADS
839
840 if ( !s_bNoAsserts )
841 {
842 // send it to the normal log destination
843 wxLogDebug(_T("%s"), msg.c_str());
844
845 if ( traits )
846 {
847 // delegate showing assert dialog (if possible) to that class
848 s_bNoAsserts = traits->ShowAssertDialog(msg);
849 }
850 else // no traits object
851 {
852 // fall back to the function of last resort
853 s_bNoAsserts = DoShowAssertDialog(msg);
854 }
855 }
856 }
857
858 #endif // __WXDEBUG__