diff options
-rw-r--r-- | include/m_gui.h | 2 | ||||
-rw-r--r-- | src/mir_core/src/CCtrlBase.cpp | 17 | ||||
-rw-r--r-- | src/mir_core/src/CCtrlPages.cpp | 2 |
3 files changed, 15 insertions, 6 deletions
diff --git a/include/m_gui.h b/include/m_gui.h index 2c3bba960b..6c00623959 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -493,7 +493,7 @@ class MIR_CORE_EXPORT CCtrlBase public:
CCtrlBase(CDlgBase *wnd, int idCtrl);
- virtual ~CCtrlBase() { }
+ virtual ~CCtrlBase();
__forceinline HWND GetHwnd() const { return m_hwnd; }
__forceinline int GetCtrlId() const { return m_idCtrl; }
diff --git a/src/mir_core/src/CCtrlBase.cpp b/src/mir_core/src/CCtrlBase.cpp index 6f57818940..6365ead6e7 100644 --- a/src/mir_core/src/CCtrlBase.cpp +++ b/src/mir_core/src/CCtrlBase.cpp @@ -44,6 +44,10 @@ CCtrlBase::CCtrlBase(CDlgBase *wnd, int idCtrl) wnd->AddControl(this); } +CCtrlBase::~CCtrlBase() +{ +} + void CCtrlBase::OnInit() { m_hwnd = (m_idCtrl && m_parentWnd && m_parentWnd->GetHwnd()) ? GetDlgItem(m_parentWnd->GetHwnd(), m_idCtrl) : nullptr; @@ -51,6 +55,14 @@ void CCtrlBase::OnInit() void CCtrlBase::OnDestroy() { + PVOID bullshit[2]; // vfptr + hwnd + bullshit[1] = m_hwnd; + CCtrlBase *pCtrl = arControls.find((CCtrlBase*)&bullshit); + if (pCtrl) { + pCtrl->Unsubclass(); + arControls.remove(pCtrl); + } + m_hwnd = nullptr; } @@ -163,11 +175,6 @@ LRESULT CALLBACK CCtrlBase::GlobalSubclassWndProc(HWND hwnd, UINT msg, WPARAM wP CCtrlBase *pCtrl = arControls.find((CCtrlBase*)&bullshit); if (pCtrl) { LRESULT res = pCtrl->CustomWndProc(msg, wParam, lParam); - if (msg == WM_DESTROY) { - pCtrl->Unsubclass(); - arControls.remove(pCtrl); - } - if (res != 0) return res; } diff --git a/src/mir_core/src/CCtrlPages.cpp b/src/mir_core/src/CCtrlPages.cpp index deb6dcd756..1d2d08694d 100644 --- a/src/mir_core/src/CCtrlPages.cpp +++ b/src/mir_core/src/CCtrlPages.cpp @@ -384,4 +384,6 @@ void CCtrlPages::OnDestroy() TabCtrl_SetImageList(m_hwnd, nullptr); ImageList_Destroy(m_hIml); } + + CSuper::OnDestroy(); } |