Don't crash on NULL tab text.

This commit is contained in:
Jon Griffiths 2004-07-16 02:30:48 +00:00 committed by Alexandre Julliard
parent 7ae8645467
commit 86a0e50a1d
1 changed files with 27 additions and 18 deletions

View File

@ -1145,7 +1145,7 @@ static void TAB_SetItemBounds (HWND hwnd)
/* Set the leftmost position of the tab. */ /* Set the leftmost position of the tab. */
infoPtr->items[curItem].rect.left = curItemLeftPos; infoPtr->items[curItem].rect.left = curItemLeftPos;
if (lStyle & TCS_FIXEDWIDTH) if ((lStyle & TCS_FIXEDWIDTH) || !infoPtr->items[curItem].pszText)
{ {
infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left + infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left +
max(infoPtr->tabWidth, icon_width); max(infoPtr->tabWidth, icon_width);
@ -1682,8 +1682,11 @@ TAB_DrawItemInterior
rcText.left = rcText.top = rcText.right = rcText.bottom = 0; rcText.left = rcText.top = rcText.right = rcText.bottom = 0;
/* get the rectangle that the text fits in */ /* get the rectangle that the text fits in */
DrawTextW(hdc, infoPtr->items[iItem].pszText, -1, if (infoPtr->items[iItem].pszText)
&rcText, DT_CALCRECT); {
DrawTextW(hdc, infoPtr->items[iItem].pszText, -1,
&rcText, DT_CALCRECT);
}
/* /*
* If not owner draw, then do the drawing ourselves. * If not owner draw, then do the drawing ourselves.
* *
@ -1824,14 +1827,17 @@ TAB_DrawItemInterior
hFont = CreateFontIndirectA(&logfont); hFont = CreateFontIndirectA(&logfont);
SelectObject(hdc, hFont); SelectObject(hdc, hFont);
ExtTextOutW(hdc, if (infoPtr->items[iItem].pszText)
(lStyle & TCS_BOTTOM) ? drawRect->right : drawRect->left, {
(!(lStyle & TCS_BOTTOM)) ? drawRect->bottom : drawRect->top, ExtTextOutW(hdc,
ETO_CLIPPED, (lStyle & TCS_BOTTOM) ? drawRect->right : drawRect->left,
drawRect, (!(lStyle & TCS_BOTTOM)) ? drawRect->bottom : drawRect->top,
infoPtr->items[iItem].pszText, ETO_CLIPPED,
lstrlenW(infoPtr->items[iItem].pszText), drawRect,
0); infoPtr->items[iItem].pszText,
lstrlenW(infoPtr->items[iItem].pszText),
0);
}
DeleteObject(hFont); DeleteObject(hFont);
} }
@ -1841,14 +1847,17 @@ TAB_DrawItemInterior
debugstr_w(infoPtr->items[iItem].pszText), center_offset_h, center_offset_v, debugstr_w(infoPtr->items[iItem].pszText), center_offset_h, center_offset_v,
drawRect->left, drawRect->top, drawRect->right, drawRect->bottom, drawRect->left, drawRect->top, drawRect->right, drawRect->bottom,
(rcText.right-rcText.left)); (rcText.right-rcText.left));
DrawTextW if (infoPtr->items[iItem].pszText)
( {
hdc, DrawTextW
infoPtr->items[iItem].pszText, (
lstrlenW(infoPtr->items[iItem].pszText), hdc,
drawRect, infoPtr->items[iItem].pszText,
DT_LEFT | DT_SINGLELINE lstrlenW(infoPtr->items[iItem].pszText),
drawRect,
DT_LEFT | DT_SINGLELINE
); );
}
} }
*drawRect = rcTemp; /* restore drawRect */ *drawRect = rcTemp; /* restore drawRect */