Author: cmihail
Date: Fri Sep 9 16:50:20 2011
New Revision: 53661
URL:
http://svn.reactos.org/svn/reactos?rev=53661&view=rev
Log:
[shell32.dll]
- Fix memory leak by from context menus.
Modified:
branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.cpp
branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.h
Modified: branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
==============================================================================
--- branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.cpp [iso-8859-1]
(original)
+++ branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.cpp [iso-8859-1] Fri Sep
9 16:50:20 2011
@@ -31,8 +31,41 @@
szPath = NULL;
}
+
CNewMenu::~CNewMenu()
{
+ UnloadShellItems();
+}
+
+void CNewMenu::UnloadItem(SHELLNEW_ITEM *item)
+{
+ // bail if the item is clearly invalid
+ if (NULL == item)
+ return;
+
+ if (NULL != item->szTarget)
+ free(item->szTarget);
+
+ free(item->szDesc);
+ free(item->szIcon);
+ free(item->szExt);
+
+ HeapFree(GetProcessHeap(), 0, item);
+}
+
+void CNewMenu::UnloadShellItems()
+{
+ SHELLNEW_ITEM *pCurItem;
+
+ while (s_SnHead)
+ {
+ pCurItem = s_SnHead;
+ s_SnHead = s_SnHead->Next;
+
+ UnloadItem(pCurItem);
+ }
+
+ s_SnHead = NULL;
}
static
@@ -85,22 +118,6 @@
RegCloseKey(hKey);
return TRUE;
-}
-
-void CNewMenu::UnloadItem(SHELLNEW_ITEM *item)
-{
- // bail if the item is clearly invalid
- if (NULL == item)
- return;
-
- if (NULL != item->szTarget)
- free(item->szTarget);
-
- free(item->szDesc);
- free(item->szIcon);
- free(item->szExt);
-
- HeapFree(GetProcessHeap(), 0, item);
}
CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPWSTR szKeyName)
@@ -200,6 +217,8 @@
if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, szNew, sizeof(szNew) /
sizeof(WCHAR)))
szNew[0] = 0;
szNew[MAX_PATH-1] = 0;
+
+ UnloadShellItems();
dwIndex = 0;
do
Modified: branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
==============================================================================
--- branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.h [iso-8859-1] (original)
+++ branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.h [iso-8859-1] Fri Sep 9
16:50:20 2011
@@ -57,6 +57,7 @@
~CNewMenu();
SHELLNEW_ITEM *LoadItem(LPWSTR szKeyName);
void UnloadItem(SHELLNEW_ITEM *item);
+ void UnloadShellItems();
BOOL LoadShellNewItems();
UINT InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu);
HRESULT DoShellNewCmd(LPCMINVOKECOMMANDINFO lpcmi);