Commit 91fbef88 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32: Never release state image list.

parent 0a23797f
......@@ -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 */
......
......@@ -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);
......
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