Commit 9e35dd15 authored by Jakub Bartmiński's avatar Jakub Bartmiński Committed by Alexandre Julliard

regedit: Fall back to tree root on invalid path.

parent 69608af0
...@@ -132,13 +132,16 @@ static LPWSTR get_path_component(LPCWSTR *lplpKeyName) { ...@@ -132,13 +132,16 @@ static LPWSTR get_path_component(LPCWSTR *lplpKeyName) {
HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) { HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
TVITEMEXW tvi; TVITEMEXW tvi;
WCHAR buf[261]; /* tree view has 260 character limitation on item name */ WCHAR buf[261]; /* tree view has 260 character limitation on item name */
HTREEITEM hItem, hOldItem; HTREEITEM hRoot, hItem, hOldItem;
BOOL valid_path;
buf[260] = '\0'; buf[260] = '\0';
hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_ROOT, 0); hRoot = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_ROOT, 0);
hItem = hRoot;
SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem ); SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem);
hOldItem = hItem; hOldItem = hItem;
valid_path = FALSE;
while(1) { while(1) {
LPWSTR lpItemName = get_path_component(&lpKeyName); LPWSTR lpItemName = get_path_component(&lpKeyName);
...@@ -150,6 +153,7 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) { ...@@ -150,6 +153,7 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
tvi.cchTextMax = 260; tvi.cchTextMax = 260;
SendMessageW(hwndTV, TVM_GETITEMW, 0, (LPARAM) &tvi); SendMessageW(hwndTV, TVM_GETITEMW, 0, (LPARAM) &tvi);
if (!lstrcmpiW(tvi.pszText, lpItemName)) { if (!lstrcmpiW(tvi.pszText, lpItemName)) {
valid_path = TRUE;
SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem ); SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
if (!lpKeyName) if (!lpKeyName)
{ {
...@@ -164,10 +168,10 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) { ...@@ -164,10 +168,10 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
} }
HeapFree(GetProcessHeap(), 0, lpItemName); HeapFree(GetProcessHeap(), 0, lpItemName);
if (!hItem) if (!hItem)
return hOldItem; return valid_path ? hOldItem : hRoot;
} }
else else
return hItem; return valid_path ? hItem : hRoot;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment