Author: hbelusca
Date: Sat Jun 29 19:22:00 2013
New Revision: 59371
URL:
http://svn.reactos.org/svn/reactos?rev=59371&view=rev
Log:
[REGEDIT]
Fix tree-view's image-list handle leakage when application quits.
Loosely based on a patch by Edijs Kolesnicovičs and Grégory Macário Harbs
NOTE: Always cleanup / destroy (or, try to) things in the reverse way they are created /
initialized (i.e. in a symmetrical way). Therefore, destry the associated tree-view's
image-list in the DestroyTreeView function, which is the opposite of CreateTreeView (which
calls InitTreeViewImageLists). The same mechanism is already used by the list-view. For
completeness, add a parameter to the DestroyTreeView function (a handle to a tree-view) so
that we can pass to it the global tree-view's handle (see what's done in
WM_DESTROY message handling in ChildWndProc).
CORE-6856 #resolve #comment Should be fixed in revision r59371. See the commit log for
more details. Thanks :)
Modified:
trunk/reactos/base/applications/regedit/childwnd.c
trunk/reactos/base/applications/regedit/main.h
trunk/reactos/base/applications/regedit/treeview.c
Modified: trunk/reactos/base/applications/regedit/childwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/regedit/…
==============================================================================
--- trunk/reactos/base/applications/regedit/childwnd.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/regedit/childwnd.c [iso-8859-1] Sat Jun 29 19:22:00
2013
@@ -439,8 +439,8 @@
}
goto def;
case WM_DESTROY:
- DestroyTreeView();
DestroyListView(g_pChildWnd->hListWnd);
+ DestroyTreeView(g_pChildWnd->hTreeWnd);
DestroyMainMenu();
HeapFree(GetProcessHeap(), 0, g_pChildWnd);
g_pChildWnd = NULL;
Modified: trunk/reactos/base/applications/regedit/main.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/regedit/…
==============================================================================
--- trunk/reactos/base/applications/regedit/main.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/regedit/main.h [iso-8859-1] Sat Jun 29 19:22:00 2013
@@ -129,9 +129,9 @@
extern HWND StartKeyRename(HWND hwndTV);
extern BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem);
extern BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath);
-extern void DestroyTreeView( void );
-extern void DestroyListView( HWND hwndLV );
-extern void DestroyMainMenu( void );
+extern void DestroyTreeView(HWND hwndTV);
+extern void DestroyListView(HWND hwndLV);
+extern void DestroyMainMenu(void);
/* edit.c */
extern BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCWSTR valueName, BOOL EditBin);
Modified: trunk/reactos/base/applications/regedit/treeview.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/regedit/…
==============================================================================
--- trunk/reactos/base/applications/regedit/treeview.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/regedit/treeview.c [iso-8859-1] Sat Jun 29 19:22:00
2013
@@ -651,10 +651,15 @@
return hwndTV;
}
-void DestroyTreeView()
-{
- if (pathBuffer)
- HeapFree(GetProcessHeap(), 0, pathBuffer);
+void DestroyTreeView(HWND hwndTV)
+{
+ HIMAGELIST himl;
+
+ if (pathBuffer) HeapFree(GetProcessHeap(), 0, pathBuffer);
+
+ /* Destroy the image list associated with the tree view control */
+ himl = TreeView_GetImageList(hwndTV, TVSIL_NORMAL);
+ if (himl) ImageList_Destroy(himl);
}
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)