https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c5f6e744e7bfdadd38c2de41b12d595651c0af95

commit c5f6e744e7bfdadd38c2de41b12d595651c0af95
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Sun Mar 6 12:33:10 2022 +0900
Commit:     Katayama Hirofumi MZ <[email protected]>
CommitDate: Sun Mar 6 12:33:10 2022 +0900

    [SHELL32] Follow-up of 'Simplify CChangeNotifyServer'
    
    Do DestroyAllItems() on OnDestroy().
    CORE-13950
---
 dll/win32/shell32/shelldesktop/CChangeNotifyServer.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/dll/win32/shell32/shelldesktop/CChangeNotifyServer.cpp 
b/dll/win32/shell32/shelldesktop/CChangeNotifyServer.cpp
index b4a46d35e8d..bb6d531ec9f 100644
--- a/dll/win32/shell32/shelldesktop/CChangeNotifyServer.cpp
+++ b/dll/win32/shell32/shelldesktop/CChangeNotifyServer.cpp
@@ -79,6 +79,7 @@ private:
     BOOL RemoveItemsByRegID(UINT nRegID);
     BOOL RemoveItemsByProcess(DWORD dwUserPID);
     void DestroyItem(CWatchItem *pItem, HWND *phwndBroker);
+    void DestroyAllItems();
 
     UINT GetNextRegID();
     BOOL DeliverNotification(HANDLE hTicket, DWORD dwOwnerPID);
@@ -136,6 +137,20 @@ void CChangeNotifyServer::DestroyItem(CWatchItem *pItem, 
HWND *phwndBroker)
     delete pItem;
 }
 
+void CChangeNotifyServer::DestroyAllItems()
+{
+    for (INT i = 0; i < m_items.GetSize(); ++i)
+    {
+        if (m_items[i])
+        {
+            HWND hwndBroker = NULL;
+            DestroyItem(m_items[i], &hwndBroker);
+            m_items[i] = NULL;
+        }
+    }
+    m_items.RemoveAll();
+}
+
 BOOL CChangeNotifyServer::RemoveItemsByRegID(UINT nRegID)
 {
     BOOL bFound = FALSE;
@@ -319,6 +334,7 @@ LRESULT CChangeNotifyServer::OnRemoveByPID(UINT uMsg, 
WPARAM wParam, LPARAM lPar
 
 LRESULT CChangeNotifyServer::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM 
lParam, BOOL& bHandled)
 {
+    DestroyAllItems();
     CDirectoryWatcher::RequestAllWatchersTermination();
     return 0;
 }

Reply via email to