X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9cce3be7ae2ee83e51c3fa91423acfa390998eaf..79e162f52668db950b1b7ff32f2f8cdcee535021:/src/common/log.cpp diff --git a/src/common/log.cpp b/src/common/log.cpp index 6e51ac79dd..d9a6c7eb30 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "log.h" #endif @@ -30,9 +30,10 @@ #if wxUSE_LOG -// wxWindows +// wxWidgets #ifndef WX_PRECOMP #include "wx/app.h" + #include "wx/arrstr.h" #include "wx/intl.h" #include "wx/string.h" #endif //WX_PRECOMP @@ -47,9 +48,17 @@ #include "wx/wxchar.h" // other standard headers +#ifndef __WXWINCE__ #include +#endif + #include + +#ifndef __WXWINCE__ #include +#else +#include "wx/msw/wince/time.h" +#endif #if defined(__WINDOWS__) #include "wx/msw/private.h" // includes windows.h @@ -178,7 +187,11 @@ void wxVLogFatalError(const wxChar *szFormat, va_list argptr) wxSafeShowMessage(_T("Fatal Error"), s_szBuf); +#ifdef __WXWINCE__ + ExitThread(3); +#else abort(); +#endif } void wxLogFatalError(const wxChar *szFormat, ...) @@ -186,7 +199,10 @@ void wxLogFatalError(const wxChar *szFormat, ...) va_list argptr; va_start(argptr, szFormat); wxVLogFatalError(szFormat, argptr); - va_end(argptr); + + // some compilers warn about unreachable code and it shouldn't matter + // for the others anyhow... + //va_end(argptr); } // same as info, but only if 'verbose' mode is on @@ -384,7 +400,7 @@ wxLog *wxLog::GetActiveTarget() // ask the application to create a log target for us if ( wxTheApp != NULL ) - ms_pLogger = wxTheApp->CreateLogTarget(); + ms_pLogger = wxTheApp->GetTraits()->CreateLogTarget(); else ms_pLogger = new wxLogStderr; @@ -425,7 +441,7 @@ void wxLog::RemoveTraceMask(const wxString& str) { int index = ms_aTraceMasks.Index(str); if ( index != wxNOT_FOUND ) - ms_aTraceMasks.Remove((size_t)index); + ms_aTraceMasks.RemoveAt((size_t)index); } void wxLog::ClearTraceMasks() @@ -454,7 +470,11 @@ void wxLog::DoLog(wxLogLevel level, const wxChar *szString, time_t t) DoLogString(wxString(_("Fatal error: ")) + szString, t); DoLogString(_("Program aborted."), t); Flush(); +#ifdef __WXWINCE__ + ExitThread(3); +#else abort(); +#endif break; case wxLOG_Error: @@ -497,6 +517,16 @@ void wxLog::Flush() // nothing to do here } +/*static*/ bool wxLog::IsAllowedTraceMask(const wxChar *mask) +{ + for ( wxArrayString::iterator it = ms_aTraceMasks.begin(), + en = ms_aTraceMasks.end(); + it != en; ++it ) + if ( *it == mask) + return true; + return false; +} + // ---------------------------------------------------------------------------- // wxLogStderr class implementation // ---------------------------------------------------------------------------- @@ -694,12 +724,7 @@ static void wxLogWrap(FILE *f, const char *pszPrefix, const char *psz) unsigned long wxSysErrorCode() { #if defined(__WXMSW__) && !defined(__WXMICROWIN__) -#ifdef __WIN32__ return ::GetLastError(); -#else //WIN16 - // TODO what to do on Windows 3.1? - return 0; -#endif //WIN16/32 #else //Unix return errno; #endif //Win/Unix @@ -712,7 +737,6 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode) nErrCode = wxSysErrorCode(); #if defined(__WXMSW__) && !defined(__WXMICROWIN__) -#ifdef __WIN32__ static wxChar s_szBuf[LOG_BUFFER_SIZE / 2]; // get error message from system @@ -724,7 +748,9 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode) 0, NULL); // copy it to our buffer and free memory - if( lpMsgBuf != 0 ) { + // Crashes on SmartPhone +#if !defined(__SMARTPHONE__) + if( lpMsgBuf != 0 ) { wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1); s_szBuf[WXSIZEOF(s_szBuf) - 1] = wxT('\0'); @@ -739,16 +765,14 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode) s_szBuf[len - 2] = wxT('\0'); } } - else { + else +#endif + { s_szBuf[0] = wxT('\0'); } return s_szBuf; -#else //Win16 - // TODO - return NULL; -#endif // Win16/32 -#else // Unix +#else // Unix-WXMICROWIN #if wxUSE_UNICODE static wxChar s_szBuf[LOG_BUFFER_SIZE / 2]; wxConvCurrent->MB2WC(s_szBuf, strerror(nErrCode), WXSIZEOF(s_szBuf) -1); @@ -756,7 +780,7 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode) #else return strerror((int)nErrCode); #endif -#endif // Win/Unix +#endif // Win/Unix-WXMICROWIN } #endif // wxUSE_LOG