Nikolay Sivov : regedit: Use notification message to clean up item data.

Alexandre Julliard julliard at winehq.org
Wed Jun 28 15:10:26 CDT 2017


Module: wine
Branch: master
Commit: b84f228805f3cf121ee2e91b155ef077b092520f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b84f228805f3cf121ee2e91b155ef077b092520f

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Jun 28 15:49:54 2017 +0300

regedit: Use notification message to clean up item data.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/regedit/listview.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c
index b758564..4be7c94 100644
--- a/programs/regedit/listview.c
+++ b/programs/regedit/listview.c
@@ -411,6 +411,14 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
 		HeapFree(GetProcessHeap(), 0, oldName);
 		return 0;
 	    }
+        case LVN_DELETEITEM: {
+                NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
+                LINE_INFO *info = (LINE_INFO *)nmlv->lParam;
+
+                HeapFree(GetProcessHeap(), 0, info->name);
+                HeapFree(GetProcessHeap(), 0, info);
+            }
+            break;
         case NM_RETURN: {
             int cnt = SendMessageW(hWnd, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0));
             if (cnt != -1)
@@ -515,7 +523,6 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
     BYTE* valBuf = 0;
     HKEY hKey = 0;
     LONG errCode;
-    INT count, i;
     LVITEMW item;
 
     if (!hwndLV) return FALSE;
@@ -525,16 +532,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
     errCode = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ, &hKey);
     if (errCode != ERROR_SUCCESS) goto done;
 
-    count = SendMessageW(hwndLV, LVM_GETITEMCOUNT, 0, 0);
-    for (i = 0; i < count; i++) {
-        item.mask = LVIF_PARAM;
-        item.iItem = i;
-        SendMessageW( hwndLV, LVM_GETITEMW, 0, (LPARAM)&item );
-        HeapFree(GetProcessHeap(), 0, ((LINE_INFO*)item.lParam)->name);
-        HeapFree(GetProcessHeap(), 0, (void*)item.lParam);
-    }
     g_columnToSort = ~0U;
-    SendMessageW( hwndLV, LVM_DELETEALLITEMS, 0, 0L );
+    SendMessageW(hwndLV, LVM_DELETEALLITEMS, 0, 0);
 
     /* get size information and resize the buffers if necessary */
     errCode = RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, &max_sub_key_len, NULL,




More information about the wine-cvs mailing list