in case the passed name was NULL, the TeamMenuItem would set a NULL label, instead of passing the 'team n' string. Also use snprintf() to build said string, and change the code a bit. malloc.h > stdlib.h, and don't check for null before calling free()
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27617 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
11b3c08b53
commit
136d40a890
@ -33,9 +33,11 @@ All rights reserved.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
@ -82,13 +84,14 @@ TTeamMenuItem::InitData(BList *team, BBitmap *icon, char *name, char *sig,
|
|||||||
fIcon = icon;
|
fIcon = icon;
|
||||||
fName = name;
|
fName = name;
|
||||||
fSig = sig;
|
fSig = sig;
|
||||||
SetLabel(name);
|
|
||||||
if (fName == NULL) {
|
if (fName == NULL) {
|
||||||
char *tmp = (char *)malloc(32);
|
char temp[32];
|
||||||
sprintf(tmp, "team %ld", (int32)team->ItemAt(0));
|
snprintf(temp, sizeof(temp), "team %ld", (int32)team->ItemAt(0));
|
||||||
fName = tmp;
|
fName = strdup(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetLabel(fName);
|
||||||
|
|
||||||
BFont font(be_plain_font);
|
BFont font(be_plain_font);
|
||||||
fLabelWidth = ceilf(font.StringWidth(fName));
|
fLabelWidth = ceilf(font.StringWidth(fName));
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
@ -419,8 +422,7 @@ TTeamMenuItem::DrawContentLabel()
|
|||||||
|
|
||||||
menu->DrawString(label);
|
menu->DrawString(label);
|
||||||
|
|
||||||
if (truncLabel)
|
free(truncLabel);
|
||||||
free(truncLabel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user