From 88408d536f4b9cc90330084dd75aff4ad7ea30ce Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 11 Nov 2015 22:31:45 +0100 Subject: [PATCH] Avoid bogus debug errors from wxWindow::SetId() in wxMSW ::SetWindowLong() can return 0 even if no error occurred but the previous value of the ID just was 0, so we need to examine the last error to know whether there really was an error -- and also to reset it to 0 before calling the function as it wouldn't reset it if it succeeds, it only sets it if it fails. --- src/msw/window.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index c1fc8169e8..2fdb69c2e8 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -512,8 +512,14 @@ void wxWindowMSW::SetId(wxWindowID winid) // changing its ID because Windows still uses the old one. if ( GetHwnd() ) { + ::SetLastError(0); + if ( !::SetWindowLong(GetHwnd(), GWL_ID, winid) ) - wxLogLastError(wxT("SetWindowLong(GWL_ID)")); + { + const DWORD err = ::GetLastError(); + if ( err ) + wxLogApiError(wxT("SetWindowLong(GWL_ID)"), err); + } } }