From 008bd05ba494fb8124d79426681c693a4d246531 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 3 Jun 2015 19:39:48 +0000 Subject: fix for the forced unsubclassing git-svn-id: http://svn.miranda-ng.org/main/trunk@13984 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/src/subclass.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/mir_core/src/subclass.cpp b/src/mir_core/src/subclass.cpp index ba7b2e5aa5..76d790f041 100644 --- a/src/mir_core/src/subclass.cpp +++ b/src/mir_core/src/subclass.cpp @@ -119,6 +119,16 @@ static void removeHook(MSubclassData *p, int idx) p->m_iHooks--; } +static WNDPROC finalizeSubclassing(HWND hWnd, MSubclassData *p) +{ + WNDPROC saveProc = p->m_origWndProc; + arSubclass.remove(p); + delete p; + + SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)saveProc); + return saveProc; +} + MIR_CORE_DLL(void) mir_unsubclassWindow(HWND hWnd, WNDPROC wndProc) { MSubclassData *p = arSubclass.find((MSubclassData*)&hWnd); @@ -132,10 +142,8 @@ MIR_CORE_DLL(void) mir_unsubclassWindow(HWND hWnd, WNDPROC wndProc) } } - if (p->m_iHooks == 0) { - arSubclass.remove(p); - delete p; - } + if (p->m_iHooks == 0) + finalizeSubclassing(hWnd, p); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -158,11 +166,7 @@ MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg if (uMsg != WM_NCDESTROY) return p->m_origWndProc(hWnd, uMsg, wParam, lParam); - WNDPROC saveProc = p->m_origWndProc; - arSubclass.remove(p); - delete p; - - SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)saveProc); + WNDPROC saveProc = finalizeSubclassing(hWnd, p); return saveProc(hWnd, uMsg, wParam, lParam); } @@ -183,9 +187,7 @@ MIR_CORE_DLL(void) KillModuleSubclassing(HMODULE hInst) } } - if (p->m_iHooks == 0) { - arSubclass.remove(p); - delete p; - } + if (p->m_iHooks == 0) + finalizeSubclassing(p->m_hWnd, p); } } -- cgit v1.2.3