[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
This commit is contained in:
Katayama Hirofumi MZ 2022-01-25 03:42:46 +09:00 committed by GitHub
parent a92304fdd4
commit c199edda45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 17 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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>

View file

@ -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;
}

View file

@ -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);
}