[PATCH 5/5] Don't send TVN_ITEMEXPANDING when item has no children
Nikolay Sivov
nsivov at codeweavers.com
Sat May 14 11:03:40 CDT 2011
---
dlls/comctl32/tests/treeview.c | 7 +++++++
dlls/comctl32/treeview.c | 18 ++++++++----------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 0b43e87..b0d09fa 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -1341,6 +1341,12 @@ static void test_expandnotify(void)
the only way is to reset with all children removed */
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "collapse after expand notifications", FALSE);
+ /* try to toggle child that doesn't have children itself */
+ flush_sequences(sequences, NUM_MSG_SEQUENCES);
+ ret = SendMessageA(hTree, TVM_EXPAND, TVE_TOGGLE, (LPARAM)hChild);
+ expect(FALSE, ret);
+ ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "toggle node without children", FALSE);
+
DestroyWindow(hTree);
/* test TVM_GETITEMRECT inside TVN_ITEMEXPANDED notification */
@@ -1350,6 +1356,7 @@ static void test_expandnotify(void)
ret = TreeView_Select(hTree, hChild, TVGN_CARET);
g_get_rect_in_expand = FALSE;
ok(ret, "got %d\n", ret);
+
DestroyWindow(hTree);
}
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index 42978d2..3e9b499 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -1450,7 +1450,7 @@ TREEVIEW_RemoveAllChildren(TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *parentIt
kill = next;
}
- assert(parentItem->cChildren <= 0); /* I_CHILDRENCALLBACK or 0 */
+ assert(parentItem->cChildren == 0 || parentItem->cChildren == I_CHILDRENCALLBACK);
assert(parentItem->firstChild == NULL);
assert(parentItem->lastChild == NULL);
}
@@ -3323,12 +3323,13 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
LONG orgNextTop = 0;
RECT scrollRect;
TREEVIEW_ITEM *nextItem, *tmpItem;
- BOOL sendsNotifications;
+ BOOL notify;
TRACE("(%p, %p, partial=%d, %d\n", infoPtr, item, partial, user);
- if (item->state & TVIS_EXPANDED)
- return TRUE;
+ if (item->state & TVIS_EXPANDED) return TRUE;
+
+ if (!item->firstChild) return FALSE;
tmpItem = item; nextItem = NULL;
while (tmpItem)
@@ -3346,9 +3347,8 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
TRACE("TVE_EXPAND %p %s\n", item, TREEVIEW_ItemName(item));
- sendsNotifications = user || ((item->cChildren != 0) &&
- !(item->state & TVIS_EXPANDEDONCE));
- if (sendsNotifications)
+ notify = user || ((item->cChildren != 0) && !(item->state & TVIS_EXPANDEDONCE));
+ if (notify)
{
if (!TREEVIEW_SendExpanding(infoPtr, item, TVE_EXPAND))
{
@@ -3356,8 +3356,6 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
return FALSE;
}
}
- if (!item->firstChild)
- return FALSE;
item->state |= TVIS_EXPANDED;
@@ -3419,7 +3417,7 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
}
}
- if (sendsNotifications) {
+ if (notify) {
TREEVIEW_SendExpanded(infoPtr, item, TVE_EXPAND);
item->state |= TVIS_EXPANDEDONCE;
}
--
1.5.6.5
--------------050602020903060502000308--
More information about the wine-patches
mailing list