Use a static_cast when removing menu item from BarMenuBar

... instead of a C-style cast. Also some minor style fixes.

Might fix #9151 although since I can't reproduce the bug here I have
no way of knowing.
This commit is contained in:
John Scipione
2012-11-14 14:00:25 -05:00
parent 963d68a632
commit cb7c5f05bb
+10 -8
View File
@@ -109,11 +109,12 @@ TBarMenuBar::AddTeamMenu()
return; return;
BRect frame(Frame()); BRect frame(Frame());
delete fAppListMenuItem;
delete fAppListMenuItem;
fAppListMenuItem = new TBarMenuTitle(0.0f, 0.0f, fAppListMenuItem = new TBarMenuTitle(0.0f, 0.0f,
AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_TeamIcon), new TTeamMenu()); AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_TeamIcon), new TTeamMenu());
AddItem(fAppListMenuItem); AddItem(fAppListMenuItem);
SmartResize(frame.Width() - 1.0f, frame.Height()); SmartResize(frame.Width() - 1.0f, frame.Height());
} }
@@ -124,13 +125,13 @@ TBarMenuBar::RemoveTeamMenu()
if (CountItems() < 2) if (CountItems() < 2)
return; return;
if (fAppListMenuItem) { if (fAppListMenuItem != NULL) {
RemoveItem((BMenuItem*)fAppListMenuItem); RemoveItem(static_cast<BMenuItem*>(fAppListMenuItem));
delete fAppListMenuItem; delete fAppListMenuItem;
fAppListMenuItem = NULL; fAppListMenuItem = NULL;
} }
BRect frame = Frame(); BRect frame(Frame());
SmartResize(frame.Width(), frame.Height()); SmartResize(frame.Width(), frame.Height());
} }
@@ -142,12 +143,13 @@ TBarMenuBar::AddSeperatorItem()
return; return;
BRect frame(Frame()); BRect frame(Frame());
delete fSeparatorItem;
delete fSeparatorItem;
fSeparatorItem = new TTeamMenuItem(kSepItemWidth, fSeparatorItem = new TTeamMenuItem(kSepItemWidth,
frame.Height() - 2, false); frame.Height() - 2, false);
AddItem(fSeparatorItem); AddItem(fSeparatorItem);
fSeparatorItem->SetEnabled(false); fSeparatorItem->SetEnabled(false);
SmartResize(frame.Width() - 1.0f, frame.Height()); SmartResize(frame.Width() - 1.0f, frame.Height());
} }
@@ -158,13 +160,13 @@ TBarMenuBar::RemoveSeperatorItem()
if (CountItems() < 2) if (CountItems() < 2)
return; return;
if (fSeparatorItem) { if (fSeparatorItem != NULL) {
RemoveItem((BMenuItem*)fSeparatorItem); RemoveItem(static_cast<BMenuItem*>(fSeparatorItem));
delete fSeparatorItem; delete fSeparatorItem;
fSeparatorItem = NULL; fSeparatorItem = NULL;
} }
BRect frame = Frame(); BRect frame(Frame());
SmartResize(frame.Width(), frame.Height()); SmartResize(frame.Width(), frame.Height());
} }