Commit 19f83e2f authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

Properly handle InsertItem with an invalid HTREEITEM. Windows handles

these like a TVI_LAST.
parent d0018bd5
...@@ -1986,27 +1986,41 @@ TREEVIEW_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1986,27 +1986,41 @@ TREEVIEW_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
wineItem->upsibling=sibItem->hItem; wineItem->upsibling=sibItem->hItem;
break; break;
default: default:
while ((sibItem->sibling) && (sibItem->hItem!=ptdi->hInsertAfter))
{ {
TREEVIEW_ITEM *localsibItem = sibItem;
while ((localsibItem->sibling) &&
(localsibItem->hItem!=ptdi->hInsertAfter))
{
prevsib=localsibItem;
localsibItem=&infoPtr->items [(INT)localsibItem->sibling];
}
if (localsibItem->hItem!=ptdi->hInsertAfter) {
WARN("tried to insert item after nonexisting handle %d treating as TVI_LAST.\n",
(INT) ptdi->hInsertAfter);
/*
* retry placing it last
*/
if (sibItem==wineItem) break;
while (sibItem->sibling) {
prevsib=sibItem; prevsib=sibItem;
sibItem=&infoPtr->items [(INT)sibItem->sibling]; sibItem=&infoPtr->items [(INT)sibItem->sibling];
} }
if (sibItem->hItem!=ptdi->hInsertAfter) { sibItem->sibling=(HTREEITEM)iItem;
ERR("tried to insert item after nonexisting handle %d.\n", wineItem->upsibling=sibItem->hItem;
(INT) ptdi->hInsertAfter);
break; break;
} }
prevsib=sibItem; prevsib=localsibItem;
if (sibItem->sibling) { if (localsibItem->sibling) {
sibItem=&infoPtr->items [(INT)sibItem->sibling]; localsibItem=&infoPtr->items [(INT)localsibItem->sibling];
sibItem->upsibling=(HTREEITEM)iItem; localsibItem->upsibling=(HTREEITEM)iItem;
wineItem->sibling=sibItem->hItem; wineItem->sibling=localsibItem->hItem;
} }
prevsib->sibling=(HTREEITEM)iItem; prevsib->sibling=(HTREEITEM)iItem;
wineItem->upsibling=prevsib->hItem; wineItem->upsibling=prevsib->hItem;
break; break;
} }
} }
}
/* Fill in info structure */ /* Fill in info structure */
......
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