Merge branch 'syserrormsgstr'

Add thread-safe wxSysErrorMsgStr() to be used instead of wxSysErrorMsg().

Closes https://github.com/wxWidgets/wxWidgets/pull/343
This commit is contained in:
Vadim Zeitlin
2016-11-27 15:08:31 +01:00
8 changed files with 83 additions and 35 deletions

View File

@@ -1188,6 +1188,9 @@ WXDLLIMPEXP_BASE unsigned long wxSysErrorCode();
// return the error message for given (or last if 0) error code
WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
// return the error message for given (or last if 0) error code
WXDLLIMPEXP_BASE wxString wxSysErrorMsgStr(unsigned long nErrCode = 0);
// ----------------------------------------------------------------------------
// define wxLog<level>() functions which can be used by application instead of
// stdio, iostream &c for log messages for easy redirection
@@ -1393,6 +1396,7 @@ public:
// Dummy macros to replace some functions.
#define wxSysErrorCode() (unsigned long)0
#define wxSysErrorMsg( X ) (const wxChar*)NULL
#define wxSysErrorMsgStr( X ) wxEmptyString
// Fake symbolic trace masks... for those that are used frequently
#define wxTRACE_OleCalls wxEmptyString // OLE interface calls
@@ -1475,13 +1479,13 @@ wxSafeShowMessage(const wxString& title, const wxString& text);
#define wxLogApiError(api, rc) \
wxLogDebug(wxT("%s(%d): '%s' failed with error 0x%08lx (%s)."), \
__FILE__, __LINE__, api, \
(long)rc, wxSysErrorMsg(rc))
(long)rc, wxSysErrorMsgStr(rc))
#else // !VC++
#define wxLogApiError(api, rc) \
wxLogDebug(wxT("In file %s at line %d: '%s' failed with ") \
wxT("error 0x%08lx (%s)."), \
__FILE__, __LINE__, api, \
(long)rc, wxSysErrorMsg(rc))
(long)rc, wxSysErrorMsgStr(rc))
#endif // VC++/!VC++
#define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode())