From 024afb5abff3e320fb70e5cfb777c6f465a00860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 29 Jun 2013 19:22:00 +0000 Subject: [PATCH] =?UTF-8?q?[REGEDIT]=20Fix=20tree-view's=20image-list=20ha?= =?UTF-8?q?ndle=20leakage=20when=20application=20quits.=20Loosely=20based?= =?UTF-8?q?=20on=20a=20patch=20by=20Edijs=20Kolesnicovi=C4=8Ds=20and=20Gr?= =?UTF-8?q?=C3=A9gory=20Mac=C3=A1rio=20Harbs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 :) svn path=/trunk/; revision=59371 --- reactos/base/applications/regedit/childwnd.c | 2 +- reactos/base/applications/regedit/main.h | 6 +++--- reactos/base/applications/regedit/treeview.c | 11 ++++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/reactos/base/applications/regedit/childwnd.c b/reactos/base/applications/regedit/childwnd.c index b5135cb94ce..f656498a3d6 100644 --- a/reactos/base/applications/regedit/childwnd.c +++ b/reactos/base/applications/regedit/childwnd.c @@ -439,8 +439,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa } goto def; case WM_DESTROY: - DestroyTreeView(); DestroyListView(g_pChildWnd->hListWnd); + DestroyTreeView(g_pChildWnd->hTreeWnd); DestroyMainMenu(); HeapFree(GetProcessHeap(), 0, g_pChildWnd); g_pChildWnd = NULL; diff --git a/reactos/base/applications/regedit/main.h b/reactos/base/applications/regedit/main.h index 46ade6bf2fd..1060c2f9dd0 100644 --- a/reactos/base/applications/regedit/main.h +++ b/reactos/base/applications/regedit/main.h @@ -129,9 +129,9 @@ extern HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name); 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); diff --git a/reactos/base/applications/regedit/treeview.c b/reactos/base/applications/regedit/treeview.c index fbd05d75898..0f1a7706839 100644 --- a/reactos/base/applications/regedit/treeview.c +++ b/reactos/base/applications/regedit/treeview.c @@ -651,10 +651,15 @@ HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, HMENU id) return hwndTV; } -void DestroyTreeView() +void DestroyTreeView(HWND hwndTV) { - if (pathBuffer) - HeapFree(GetProcessHeap(), 0, pathBuffer); + 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)