https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d958950217f67dd0a7703…
commit d958950217f67dd0a77035fd1e5f827b0f793e65
Author:     Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Jan 24 10:26:13 2022 +0900
Commit:     GitHub <noreply(a)github.com>
CommitDate: Mon Jan 24 10:26:13 2022 +0900
    [EXPLORER] Enable _DEBUG and fix assertion failures (#4306)
    - Enable _DEBUG if debugging.
    - Fix assertion failures.
    CORE-18013
---
 base/shell/explorer/precomp.h    |  4 ++++
 base/shell/explorer/syspager.cpp |  6 ++++--
 base/shell/explorer/taskswnd.cpp |  3 ++-
 base/shell/explorer/traywnd.cpp  | 12 +++++++-----
 4 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/base/shell/explorer/precomp.h b/base/shell/explorer/precomp.h
index efce3c2a233..0080f6806e0 100644
--- a/base/shell/explorer/precomp.h
+++ b/base/shell/explorer/precomp.h
@@ -9,6 +9,10 @@
 #define WIN7_COMPAT_MODE 1
 #endif
+#if DBG && !defined(_DEBUG)
+    #define _DEBUG     // CORE-17505
+#endif
+
 #include <stdio.h>
 #include <tchar.h>
diff --git a/base/shell/explorer/syspager.cpp b/base/shell/explorer/syspager.cpp
index b28e742cef4..072f1ef522b 100644
--- a/base/shell/explorer/syspager.cpp
+++ b/base/shell/explorer/syspager.cpp
@@ -1231,8 +1231,10 @@ void CNotifyToolbar::Initialize(HWND hWndParent, CBalloonQueue *
queue)
         TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_WRAPABLE | TBSTYLE_TRANSPARENT |
         CCS_TOP | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER;
-    // HACK & FIXME: CORE-17505
-    SubclassWindow(CToolbar::Create(hWndParent, styles));
+    // HACK & FIXME: CORE-18016
+    HWND hwnd = CToolbar::Create(hWndParent, styles);
+    m_hWnd = NULL;
+    SubclassWindow(hwnd);
     // Force the toolbar tooltips window to always show tooltips even if not foreground
     HWND tooltipsWnd = (HWND)SendMessageW(TB_GETTOOLTIPS);
diff --git a/base/shell/explorer/taskswnd.cpp b/base/shell/explorer/taskswnd.cpp
index caa725fc14e..e7f224ea136 100644
--- a/base/shell/explorer/taskswnd.cpp
+++ b/base/shell/explorer/taskswnd.cpp
@@ -285,9 +285,10 @@ public:
             TBSTYLE_TOOLTIPS | TBSTYLE_WRAPABLE | TBSTYLE_LIST | TBSTYLE_TRANSPARENT |
             CCS_TOP | CCS_NORESIZE | CCS_NODIVIDER;
+        // HACK & FIXME: CORE-18016
         HWND toolbar = CToolbar::Create(hWndParent, styles);
         SetDrawTextFlags(DT_NOPREFIX, DT_NOPREFIX);
-        // HACK & FIXME: CORE-17505
+        m_hWnd = NULL;
         return SubclassWindow(toolbar);
     }
 };
diff --git a/base/shell/explorer/traywnd.cpp b/base/shell/explorer/traywnd.cpp
index 57acf0d28a0..c4a30a6ffe3 100644
--- a/base/shell/explorer/traywnd.cpp
+++ b/base/shell/explorer/traywnd.cpp
@@ -200,8 +200,10 @@ public:
     VOID Initialize()
     {
-        // HACK & FIXME: CORE-17505
-        SubclassWindow(m_hWnd);
+        // HACK & FIXME: CORE-18016
+        HWND hWnd = m_hWnd;
+        m_hWnd = NULL;
+        SubclassWindow(hWnd);
         SetWindowTheme(m_hWnd, L"Start", NULL);
@@ -216,8 +218,6 @@ public:
         UpdateSize();
     }
-    // Hack:
-    // Use DECLARE_WND_SUPERCLASS instead!
     HWND Create(HWND hwndParent)
     {
         WCHAR szStartCaption[32];
@@ -231,6 +231,7 @@ public:
         DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | BS_PUSHBUTTON | BS_LEFT
| BS_VCENTER;
+        // HACK & FIXME: CORE-18016
         m_hWnd = CreateWindowEx(
             0,
             WC_BUTTON,
@@ -3327,6 +3328,7 @@ public:
         if (TrayWnd->m_TrayBandSite != NULL)
         {
+            pcm.Release();
             if (FAILED(TrayWnd->m_TrayBandSite->AddContextMenus(
                 hPopup,
                 indexMenu,
@@ -3336,7 +3338,7 @@ public:
                 &pcm)))
             {
                 WARN("AddContextMenus failed.\n");
-                pcm = NULL;
+                pcm.Release();
             }
         }