Properly handle InsertItem with an invalid HTREEITEM. Windows handles

these like a TVI_LAST.
This commit is contained in:
Aric Stewart 2000-06-08 19:21:41 +00:00 committed by Alexandre Julliard
parent d0018bd547
commit 19f83e2f6a
1 changed files with 25 additions and 11 deletions

View File

@ -1986,25 +1986,39 @@ 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=sibItem; prevsib=localsibItem;
sibItem=&infoPtr->items [(INT)sibItem->sibling]; localsibItem=&infoPtr->items [(INT)localsibItem->sibling];
} }
if (sibItem->hItem!=ptdi->hInsertAfter) { if (localsibItem->hItem!=ptdi->hInsertAfter) {
ERR("tried to insert item after nonexisting handle %d.\n", WARN("tried to insert item after nonexisting handle %d treating as TVI_LAST.\n",
(INT) ptdi->hInsertAfter); (INT) ptdi->hInsertAfter);
break; /*
* retry placing it last
*/
if (sibItem==wineItem) break;
while (sibItem->sibling) {
prevsib=sibItem;
sibItem=&infoPtr->items [(INT)sibItem->sibling];
}
sibItem->sibling=(HTREEITEM)iItem;
wineItem->upsibling=sibItem->hItem;
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;
}
} }
} }