Listview AC0
Dimitrie O. Paun
dpaun at rogers.com
Tue Dec 10 00:43:26 CST 2002
ChangeLog
-- Plug a bunch of memory leaks
-- Make rages_destroy behave more like free()
-- Fix messed up indentation from tabs set to 4 chars
-- Updated the documentation
Index: dlls/comctl32/listview.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/listview.c,v
retrieving revision 1.332
diff -u -r1.332 listview.c
--- dlls/comctl32/listview.c 2 Dec 2002 18:11:00 -0000 1.332
+++ dlls/comctl32/listview.c 10 Dec 2002 06:38:38 -0000
@@ -45,13 +45,15 @@
* -- LVA_SNAPTOGRID not implemented
* -- LISTVIEW_ApproximateViewRect partially implemented
* -- LISTVIEW_[GS]etColumnOrderArray stubs
- * -- LISTVIEW_GetNextItem is very inefficient
* -- LISTVIEW_SetColumnWidth ignores header images & bitmap
* -- LISTVIEW_SetIconSpacing is incomplete
* -- LISTVIEW_SortItems is broken
* -- LISTVIEW_StyleChanged doesn't handle some changes too well
*
* Speedups
+ * -- LISTVIEW_GetNextItem needs to be rewritten. It is currently
+ * linear in the number of items in the list, and this is
+ * unacceptable for large lists.
* -- in sorted mode, LISTVIEW_InsertItemT sorts the array,
* instead of inserting in the right spot
* -- we should keep an ordered array of coordinates in iconic mode
@@ -785,16 +787,16 @@
if (convertToAnsi)
{
- if (notificationCode != LVN_GETDISPINFOW)
- {
+ if (notificationCode != LVN_GETDISPINFOW)
+ {
cchTempBufMax = WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText,
-1, NULL, 0, NULL, NULL);
}
- else
- {
- cchTempBufMax = pdi->item.cchTextMax;
- *pdi->item.pszText = 0; /* make sure we don't process garbage */
- }
+ else
+ {
+ cchTempBufMax = pdi->item.cchTextMax;
+ *pdi->item.pszText = 0; /* make sure we don't process garbage */
+ }
pszTempBuf = HeapAlloc(GetProcessHeap(), 0, sizeof(CHAR) *
cchTempBufMax);
@@ -1016,7 +1018,7 @@
*/
static inline void iterator_destroy(ITERATOR* i)
{
- if (i->ranges) ranges_destroy(i->ranges);
+ ranges_destroy(i->ranges);
}
/***
@@ -2423,6 +2425,7 @@
static void ranges_destroy(RANGES ranges)
{
+ if (!ranges) return;
ranges_clear(ranges);
DPA_Destroy(ranges->hdpa);
COMCTL32_Free(ranges);
@@ -2446,7 +2449,7 @@
fail:
TRACE ("clone failed\n");
- if (clone) ranges_destroy(clone);
+ ranges_destroy(clone);
return NULL;
}
@@ -7013,6 +7016,7 @@
WS_CHILD | HDS_HORZ | (DWORD)((LVS_NOSORTHEADER & lpcs->style)?0:HDS_BUTTONS),
0, 0, 0, 0, hwnd, NULL,
lpcs->hInstance, NULL);
+ if (!infoPtr->hwndHeader) goto fail;
/* set header unicode format */
SendMessageW(infoPtr->hwndHeader, HDM_SETUNICODEFORMAT, (WPARAM)TRUE, (LPARAM)NULL);
@@ -7020,15 +7024,12 @@
/* set header font */
SendMessageW(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)infoPtr->hFont, (LPARAM)TRUE);
- /* allocate memory for the selection ranges */
- if (!(infoPtr->selectionRanges = ranges_create(10))) return -1;
-
/* allocate memory for the data structure */
- /* FIXME: what if we fail? */
- infoPtr->hdpaItems = DPA_Create(10);
- infoPtr->hdpaPosX = DPA_Create(10);
- infoPtr->hdpaPosY = DPA_Create(10);
- infoPtr->hdpaColumns = DPA_Create(10);
+ if (!(infoPtr->selectionRanges = ranges_create(10))) goto fail;
+ if (!(infoPtr->hdpaItems = DPA_Create(10))) goto fail;
+ if (!(infoPtr->hdpaPosX = DPA_Create(10))) goto fail;
+ if (!(infoPtr->hdpaPosY = DPA_Create(10))) goto fail;
+ if (!(infoPtr->hdpaColumns = DPA_Create(10))) goto fail;
/* initialize the icon sizes */
set_icon_size(&infoPtr->iconSize, infoPtr->himlNormal, uView != LVS_ICON);
@@ -7052,6 +7053,16 @@
}
return 0;
+
+fail:
+ DestroyWindow(infoPtr->hwndHeader);
+ ranges_destroy(infoPtr->selectionRanges);
+ DPA_Destroy(infoPtr->hdpaItems);
+ DPA_Destroy(infoPtr->hdpaPosX);
+ DPA_Destroy(infoPtr->hdpaPosY);
+ DPA_Destroy(infoPtr->hdpaColumns);
+ COMCTL32_Free(infoPtr);
+ return -1;
}
/***
@@ -7656,7 +7667,10 @@
/* destroy data structure */
DPA_Destroy(infoPtr->hdpaItems);
- if (infoPtr->selectionRanges) ranges_destroy(infoPtr->selectionRanges);
+ DPA_Destroy(infoPtr->hdpaPosX);
+ DPA_Destroy(infoPtr->hdpaPosY);
+ DPA_Destroy(infoPtr->hdpaColumns);
+ ranges_destroy(infoPtr->selectionRanges);
/* destroy image lists */
if (!(infoPtr->dwStyle & LVS_SHAREIMAGELISTS))
@@ -8726,7 +8740,6 @@
{
SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE |
SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE);
- /* FIXME: why do we need this here? */
LISTVIEW_UpdateSize(infoPtr);
LISTVIEW_UpdateScroll(infoPtr);
}
--
Dimi.
More information about the wine-patches
mailing list