Nikolay Sivov : comctl32: Never release state image list.
Alexandre Julliard
julliard at winehq.org
Mon Jan 30 14:05:53 CST 2012
Module: wine
Branch: master
Commit: 91fbef88bf1801f1a3a62d8648ce689a4c402600
URL: http://source.winehq.org/git/wine.git/?a=commit;h=91fbef88bf1801f1a3a62d8648ce689a4c402600
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun Jan 29 19:27:17 2012 +0300
comctl32: Never release state image list.
---
dlls/comctl32/tests/treeview.c | 27 +++++++++++++++++++++++++--
dlls/comctl32/treeview.c | 14 --------------
2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index c99d480..8c0ec93 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -1607,9 +1607,9 @@ static void test_htreeitem_layout(void)
static void test_TVS_CHECKBOXES(void)
{
- HIMAGELIST himl;
+ HIMAGELIST himl, himl2;
+ HWND hTree, hTree2;
TVITEMA item;
- HWND hTree;
DWORD ret;
hTree = create_treeview_control(0);
@@ -1639,6 +1639,10 @@ static void test_TVS_CHECKBOXES(void)
himl = (HIMAGELIST)SendMessageA(hTree, TVM_GETIMAGELIST, TVSIL_STATE, 0);
ok(himl != NULL, "got %p\n", himl);
+ himl2 = (HIMAGELIST)SendMessageA(hTree, TVM_GETIMAGELIST, TVSIL_STATE, 0);
+ ok(himl2 != NULL, "got %p\n", himl2);
+ ok(himl2 == himl, "got %p, expected %p\n", himl2, himl);
+
item.hItem = hRoot;
item.mask = TVIF_STATE;
item.state = 0;
@@ -1655,6 +1659,25 @@ static void test_TVS_CHECKBOXES(void)
expect(TRUE, ret);
ok(item.state == INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item.state);
+ /* create another control and check its checkbox list */
+ hTree2 = create_treeview_control(0);
+ fill_tree(hTree2);
+
+ /* set some index for a child */
+ item.hItem = hChild;
+ item.mask = TVIF_STATE;
+ item.state = INDEXTOSTATEIMAGEMASK(4);
+ item.stateMask = TVIS_STATEIMAGEMASK;
+ ret = SendMessageA(hTree2, TVM_SETITEMA, 0, (LPARAM)&item);
+ expect(TRUE, ret);
+
+ /* enabling check boxes set all items to 1 state image index */
+ SetWindowLongA(hTree2, GWL_STYLE, GetWindowLongA(hTree, GWL_STYLE) | TVS_CHECKBOXES);
+ himl2 = (HIMAGELIST)SendMessageA(hTree2, TVM_GETIMAGELIST, TVSIL_STATE, 0);
+ ok(himl2 != NULL, "got %p\n", himl2);
+ ok(himl != himl2, "got %p, expected %p\n", himl2, himl);
+
+ DestroyWindow(hTree2);
DestroyWindow(hTree);
/* the same, but initially created with TVS_CHECKBOXES */
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index c5f3bb3..3f4fdc6 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -66,14 +66,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(treeview);
-enum StateListType
-{
- OriginInternal,
- OriginUser
-};
-
/* internal structures */
-
typedef struct _TREEITEM /* HTREEITEM is a _TREEINFO *. */
{
HTREEITEM parent; /* handle to parent or 0 if at root */
@@ -162,7 +155,6 @@ typedef struct tagTREEVIEW_INFO
HIMAGELIST himlState;
int stateImageHeight;
int stateImageWidth;
- enum StateListType statehimlType;
HDPA items;
DWORD lastKeyPressTimestamp;
@@ -1793,11 +1785,8 @@ TREEVIEW_SetImageList(TREEVIEW_INFO *infoPtr, UINT type, HIMAGELIST himlNew)
infoPtr->himlState = himlNew;
if (himlNew)
- {
ImageList_GetIconSize(himlNew, &infoPtr->stateImageWidth,
&infoPtr->stateImageHeight);
- infoPtr->statehimlType = OriginUser;
- }
else
{
infoPtr->stateImageWidth = 0;
@@ -4970,7 +4959,6 @@ TREEVIEW_InitCheckboxes(TREEVIEW_INFO *infoPtr)
int nIndex;
infoPtr->himlState = ImageList_Create(16, 16, ILC_COLOR | ILC_MASK, 3, 0);
- infoPtr->statehimlType = OriginInternal;
hdcScreen = GetDC(0);
@@ -5134,8 +5122,6 @@ TREEVIEW_Destroy(TREEVIEW_INFO *infoPtr)
CloseThemeData (GetWindowTheme (infoPtr->hwnd));
- if (infoPtr->statehimlType == OriginInternal)
- ImageList_Destroy(infoPtr->himlState);
/* Deassociate treeview from the window before doing anything drastic. */
SetWindowLongPtrW(infoPtr->hwnd, 0, 0);
More information about the wine-cvs
mailing list