https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c199edda45cdc4b228847…
commit c199edda45cdc4b228847a2b02e06326c37f3c2b
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Jan 25 03:42:46 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Jan 25 03:42:46 2022 +0900
[SHELL32] Enable _DEBUG and fix assertion failures (#4307)
Improve debuggability. Fix "WorkerW" window class conflict.
- Enable _DEBUG macro if debugging, in order to enable ATLASSERT macro.
- Fix assertion failures.
- Add SHCreateDefaultWorkerWindow helper function and CWorkerTraits, then use them.
- Don't create the broker and server windows by themselves, but subclass.
CORE-17505, CORE-13950
---
dll/win32/shell32/CDefView.cpp | 3 ++-
dll/win32/shell32/changenotify.cpp | 11 ++++-------
dll/win32/shell32/precomp.h | 4 ++++
dll/win32/shell32/shelldesktop/CChangeNotifyServer.cpp | 13 ++++---------
dll/win32/shell32/shelldesktop/CChangeNotifyServer.h | 12 ++++++++++++
5 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp
index 45d1e4ce827..8ee02097f55 100644
--- a/dll/win32/shell32/CDefView.cpp
+++ b/dll/win32/shell32/CDefView.cpp
@@ -1027,7 +1027,8 @@ HRESULT CDefView::FillList()
LRESULT CDefView::OnShowWindow(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
{
- m_ListView.UpdateWindow();
+ if (m_ListView.IsWindow())
+ m_ListView.UpdateWindow();
bHandled = FALSE;
return 0;
}
diff --git a/dll/win32/shell32/changenotify.cpp b/dll/win32/shell32/changenotify.cpp
index c35201cce7c..4666771734b 100644
--- a/dll/win32/shell32/changenotify.cpp
+++ b/dll/win32/shell32/changenotify.cpp
@@ -66,14 +66,9 @@ EXTERN_C void FreeChangeNotifications(void)
// The new delivery method is enabled by SHCNRF_NewDelivery flag.
// With the new delivery method the server directly sends the delivery message.
-typedef CWinTraits <
- WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
- WS_EX_TOOLWINDOW
-> CBrokerTraits;
-
// This class brokers all notifications that don't have the SHCNRF_NewDelivery flag
class CChangeNotifyBroker :
- public CWindowImpl<CChangeNotifyBroker, CWindow, CBrokerTraits>
+ public CWindowImpl<CChangeNotifyBroker, CWindow, CWorkerTraits>
{
public:
CChangeNotifyBroker(HWND hwndClient, UINT uMsg) :
@@ -139,13 +134,15 @@ CreateNotificationBroker(HWND hwnd, UINT wMsg)
return NULL;
}
- HWND hwndBroker = pBroker->Create(0);
+ HWND hwndBroker = SHCreateDefaultWorkerWindow();
if (hwndBroker == NULL)
{
ERR("hwndBroker == NULL\n");
delete pBroker;
+ return NULL;
}
+ pBroker->SubclassWindow(hwndBroker);
return hwndBroker;
}
diff --git a/dll/win32/shell32/precomp.h b/dll/win32/shell32/precomp.h
index 9b422353e6c..983e619d358 100644
--- a/dll/win32/shell32/precomp.h
+++ b/dll/win32/shell32/precomp.h
@@ -1,6 +1,10 @@
#ifndef _PRECOMP_H__
#define _PRECOMP_H__
+#if DBG && !defined(_DEBUG)
+ #define _DEBUG // CORE-17505
+#endif
+
#include <stdarg.h>
#include <assert.h>
diff --git a/dll/win32/shell32/shelldesktop/CChangeNotifyServer.cpp
b/dll/win32/shell32/shelldesktop/CChangeNotifyServer.cpp
index c0835faa919..55918cad656 100644
--- a/dll/win32/shell32/shelldesktop/CChangeNotifyServer.cpp
+++ b/dll/win32/shell32/shelldesktop/CChangeNotifyServer.cpp
@@ -23,11 +23,6 @@ struct ITEM
CDirectoryWatcher *pDirWatch; // for filesystem notification
};
-typedef CWinTraits <
- WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
- WS_EX_TOOLWINDOW
-> CChangeNotifyServerTraits;
-
//////////////////////////////////////////////////////////////////////////////
// CChangeNotifyServer
//
@@ -37,7 +32,7 @@ typedef CWinTraits <
// to this window where all processing takes place.
class CChangeNotifyServer :
- public CWindowImpl<CChangeNotifyServer, CWindow, CChangeNotifyServerTraits>,
+ public CWindowImpl<CChangeNotifyServer, CWindow, CWorkerTraits>,
public CComObjectRootEx<CComMultiThreadModelNoCS>,
public IOleWindow
{
@@ -470,10 +465,10 @@ HRESULT WINAPI CChangeNotifyServer::ContextSensitiveHelp(BOOL
fEnterMode)
HRESULT CChangeNotifyServer::Initialize()
{
// This is called by CChangeNotifyServer_CreateInstance right after instantiation.
- // Create the window of the server here.
- Create(0);
- if (!m_hWnd)
+ HWND hwnd = SHCreateDefaultWorkerWindow();
+ if (!hwnd)
return E_FAIL;
+ SubclassWindow(hwnd);
return S_OK;
}
diff --git a/dll/win32/shell32/shelldesktop/CChangeNotifyServer.h
b/dll/win32/shell32/shelldesktop/CChangeNotifyServer.h
index 4c5dc9083de..3f6e5174fce 100644
--- a/dll/win32/shell32/shelldesktop/CChangeNotifyServer.h
+++ b/dll/win32/shell32/shelldesktop/CChangeNotifyServer.h
@@ -6,6 +6,8 @@
*/
#pragma once
+#include <shlwapi_undoc.h> // for SHCreateWorkerWindowW
+
/////////////////////////////////////////////////////////////////////////////
// CChangeNotifyServer is a delivery worker window that is managed by CDesktopBrowser.
// The process of CChangeNotifyServer is same as the process of CDesktopBrowser.
@@ -89,3 +91,13 @@ typedef struct HANDBAG
#define HANDBAG_MAGIC 0xFACEB00C
HRESULT CChangeNotifyServer_CreateInstance(REFIID riid, void **ppv);
+
+#define WORKER_STYLE (WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN)
+#define WORKER_EXSTYLE WS_EX_TOOLWINDOW
+
+typedef CWinTraits<WORKER_STYLE, WORKER_EXSTYLE> CWorkerTraits;
+
+inline HWND SHCreateDefaultWorkerWindow(VOID)
+{
+ return SHCreateWorkerWindowW(NULL, NULL, WORKER_EXSTYLE, WORKER_STYLE, NULL, 0);
+}