Merge branch 'formatmessage-ignore-inserts' of https://github.com/lanurmi/wxWidgets

Fix GetSysErrorMsg() (used by wxLogLastError() under MSW) to work with
error messages containing inserts.

See https://github.com/wxWidgets/wxWidgets/pull/1317
This commit is contained in:
Vadim Zeitlin 2019-05-18 14:21:20 +02:00
commit 7fee108177

View File

@ -1066,7 +1066,8 @@ static const wxChar* GetSysErrorMsg(wxChar* szBuf, size_t sizeBuf, unsigned long
LPVOID lpMsgBuf;
if ( ::FormatMessage
(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
nErrCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
@ -1075,9 +1076,11 @@ static const wxChar* GetSysErrorMsg(wxChar* szBuf, size_t sizeBuf, unsigned long
NULL
) == 0 )
{
wxLogDebug(wxS("FormatMessage failed with error 0x%lx in %s"),
GetLastError(), __WXFUNCTION__ ? __WXFUNCTION__ : "");
// if this happens, something is seriously wrong, so don't use _() here
// for safety
wxSprintf(szBuf, wxS("unknown error %lx"), nErrCode);
wxSprintf(szBuf, wxS("unknown error 0x%lx"), nErrCode);
return szBuf;
}