comctl32: header: Mark the callback items in a mask.
Mark the callback items in the callbackMask HEADER_ITEM field. The
pszText for callback texts is now NULL what simplifies some
checks. Checks for lpItem->pszText==emptyString are also not needed as
emptyString is not stored in lpItem but used as a parameter to
Str_SetPtr (I haven't noticed it).
diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c
index bed77ca..05ec599 100644
--- a/dlls/comctl32/header.c
+++ b/dlls/comctl32/header.c
@@ -61,6 +61,7 @@
BOOL bDown; /* is item pressed? (used for drawing) */
RECT rect; /* bounding rectangle of the item */
+ DWORD callbackMask; /* HDI_* flags for items that are callback */
} HEADER_ITEM;
@@ -103,8 +104,7 @@
static void HEADER_DisposeItem(HEADER_ITEM *lpItem)
{
- if (lpItem->pszText && lpItem->pszText != emptyString &&
- lpItem->pszText != LPSTR_TEXTCALLBACKW) /* covers LPSTR_TEXTCALLBACKA too */
+ if (lpItem->pszText)
{
Free(lpItem->pszText);
}
@@ -127,14 +127,17 @@
if (phdi->mask & HDI_IMAGE)
{
lpItem->iImage = phdi->iImage;
+ if (phdi->iImage == I_IMAGECALLBACK)
+ lpItem->callbackMask |= HDI_IMAGE;
+ else
+ lpItem->callbackMask &= ~HDI_IMAGE;
}
if (phdi->mask & HDI_TEXT)
{
if (lpItem->pszText)
{
- if (lpItem->pszText != emptyString && lpItem->pszText != LPSTR_TEXTCALLBACKW)
- Free(lpItem->pszText);
+ Free(lpItem->pszText);
lpItem->pszText = NULL;
}
@@ -145,10 +148,12 @@
Str_SetPtrW(&lpItem->pszText, pszText);
else
Str_SetPtrAtoW(&lpItem->pszText, (LPSTR)pszText);
+ lpItem->callbackMask &= ~HDI_TEXT;
}
else
{
- lpItem->pszText = phdi->pszText;
+ lpItem->pszText = NULL;
+ lpItem->callbackMask |= HDI_TEXT;
}
}
}
@@ -777,6 +782,7 @@
if (dispInfo.mask & HDI_IMAGE)
{
lpItem->iImage = dispInfo.iImage;
+ lpItem->callbackMask &= ~HDI_IMAGE;
}
if (dispInfo.mask & HDI_TEXT)
{
@@ -784,6 +790,7 @@
Str_SetPtrW(&lpItem->pszText, (LPCWSTR)dispInfo.pszText);
else /*if (convertToAnsi || !isW)*/
Str_SetPtrAtoW(&lpItem->pszText, (LPCSTR)dispInfo.pszText);
+ lpItem->callbackMask &= ~HDI_TEXT;
}
FIXME("NMHDDISPINFO returns with flags HDI_DI_SETITEM\n");
@@ -949,7 +956,7 @@
if (phdi->mask & HDI_IMAGE)
{
phdi->iImage = lpItem->iImage;
- if (lpItem->iImage == I_IMAGECALLBACK)
+ if (lpItem->callbackMask & HDI_IMAGE)
{
HEADER_SendHeaderDispInfoNotify(hwnd, nItem, HDI_IMAGE, phdi, lpItem, bUnicode);
}
@@ -960,7 +967,7 @@
if (phdi->mask & HDI_TEXT)
{
- if (lpItem->pszText == LPSTR_TEXTCALLBACKW) /* covers == TEXTCALLBACKA too */
+ if (lpItem->callbackMask & HDI_TEXT)
{
HEADER_SendHeaderDispInfoNotify(hwnd, nItem, HDI_TEXT, phdi, lpItem, bUnicode);
}