Commit a982259e authored by Adam Gundy's avatar Adam Gundy Committed by Alexandre Julliard

When items are inserted in a partially populated treeview, the first

visible item was not correctly updated. The first visible item was sometimes used to calculate the location of other items when it had been freed.
parent 06d610ec
...@@ -988,6 +988,16 @@ TREEVIEW_FreeItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item) ...@@ -988,6 +988,16 @@ TREEVIEW_FreeItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
COMCTL32_Free(item); COMCTL32_Free(item);
if (infoPtr->selectedItem == item) if (infoPtr->selectedItem == item)
infoPtr->selectedItem = NULL; infoPtr->selectedItem = NULL;
if (infoPtr->hotItem == item)
infoPtr->hotItem = NULL;
if (infoPtr->focusedItem == item)
infoPtr->focusedItem = NULL;
if (infoPtr->firstVisible == item)
infoPtr->firstVisible = NULL;
if (infoPtr->dropItem == item)
infoPtr->dropItem = NULL;
if (infoPtr->insertMarkItem == item)
infoPtr->insertMarkItem = NULL;
} }
...@@ -1216,9 +1226,12 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam) ...@@ -1216,9 +1226,12 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam)
switch ((DWORD)insertAfter) switch ((DWORD)insertAfter)
{ {
case (DWORD)TVI_FIRST: case (DWORD)TVI_FIRST:
TREEVIEW_InsertBefore(newItem, parentItem->firstChild, parentItem); {
if (infoPtr->firstVisible == parentItem->firstChild) TREEVIEW_ITEM *originalFirst = parentItem->firstChild;
TREEVIEW_SetFirstVisible(infoPtr, newItem, TRUE); TREEVIEW_InsertBefore(newItem, parentItem->firstChild, parentItem);
if (infoPtr->firstVisible == originalFirst)
TREEVIEW_SetFirstVisible(infoPtr, newItem, TRUE);
}
break; break;
case (DWORD)TVI_LAST: case (DWORD)TVI_LAST:
...@@ -1531,6 +1544,7 @@ TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM wineItem) ...@@ -1531,6 +1544,7 @@ TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM wineItem)
newFirstVisible = wineItem->prevSibling; newFirstVisible = wineItem->prevSibling;
else if (wineItem->parent != infoPtr->root) else if (wineItem->parent != infoPtr->root)
newFirstVisible = wineItem->parent; newFirstVisible = wineItem->parent;
TREEVIEW_SetFirstVisible(infoPtr, NULL, TRUE);
} }
else else
newFirstVisible = infoPtr->firstVisible; newFirstVisible = infoPtr->firstVisible;
...@@ -1564,8 +1578,8 @@ TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM wineItem) ...@@ -1564,8 +1578,8 @@ TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM wineItem)
if (visible) if (visible)
{ {
TREEVIEW_RecalculateVisibleOrder(infoPtr, prev);
TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE); TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE);
TREEVIEW_RecalculateVisibleOrder(infoPtr, prev);
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
TREEVIEW_Invalidate(infoPtr, NULL); TREEVIEW_Invalidate(infoPtr, NULL);
} }
......
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