From fdbed751dc4958b42ba665e7e7bcfb70734d8f2a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 15 Nov 2015 01:10:02 +0100 Subject: [PATCH] Fix MSVC wxMSW build with wxDEBUG_LEVEL>=2 This was broken since 39ad820bee987fee118cef2282bd88ff96633b41 which added wxSEH_TRY to wxWndProc() which uses a local object with dtor when wxDEBUG_LEVEL>=2 and so broke its compilation with MSVC which doesn't allow the use of dtors in functions also using SEH. Closes #17095. --- src/msw/window.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 2fdb69c2e8..6c5ff9ea91 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -232,9 +232,16 @@ bool gs_insideCaptureChanged = false; LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - #if wxDEBUG_LEVEL >= 2 - const wxChar *wxGetMessageName(int message); +const wxChar *wxGetMessageName(int message); + +inline +void wxTraceMSWMessage(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + wxLogTrace("winmsg", + wxT("Processing %s(hWnd=%p, wParam=%p, lParam=%p)"), + wxGetMessageName(message), hWnd, wParam, lParam); +} #endif // wxDEBUG_LEVEL >= 2 void wxRemoveHandleAssociation(wxWindowMSW *win); @@ -2604,14 +2611,10 @@ wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) // trace all messages: useful for the debugging but noticeably slows down // the code so don't do it by default #if wxDEBUG_LEVEL >= 2 - // notice that we cast wParam and lParam to long to avoid mismatch with - // format specifiers in 64 bit builds where they are both int64 quantities - // - // casting like this loses information, of course, but it shouldn't matter - // much for this diagnostic code and it keeps the code simple - wxLogTrace("winmsg", - wxT("Processing %s(hWnd=%p, wParam=%08lx, lParam=%08lx)"), - wxGetMessageName(message), hWnd, (long)wParam, (long)lParam); + // We have to do this inside a helper function as wxLogTrace() constructs + // an object internally, but objects can't be used in functions using __try + // (expanded from wxSEH_TRY below) with MSVC. + wxTraceMSWMessage(hWnd, message, wParam, lParam); #endif // wxDEBUG_LEVEL >= 2 wxWindowMSW *wnd = wxFindWinFromHandle(hWnd);