some changes, fixed a possible segfault

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15573 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2005-12-17 21:45:18 +00:00
parent 5352d6baaa
commit b8fe2d4ed5
+13 -23
View File
@@ -255,19 +255,17 @@ BMenu::AttachedToWindow()
{ {
BView::AttachedToWindow(); BView::AttachedToWindow();
bool aborted = false;
if (AddDynamicItem(B_INITIAL_ADD)) { if (AddDynamicItem(B_INITIAL_ADD)) {
do { do {
if (!OkToProceed(NULL)) { if (!OkToProceed(NULL)) {
AddDynamicItem(B_ABORT); AddDynamicItem(B_ABORT);
aborted = true; fAttachAborted = true;
break; break;
} }
} while (AddDynamicItem(B_PROCESSING)); } while (AddDynamicItem(B_PROCESSING));
} }
if (!aborted) if (!fAttachAborted)
InvalidateLayout(); InvalidateLayout();
} }
@@ -756,9 +754,8 @@ BMenu::InvalidateLayout()
BHandler * BHandler *
BMenu::ResolveSpecifier(BMessage *msg, int32 index, BMenu::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier,
BMessage *specifier, int32 form, int32 form, const char *property)
const char *property)
{ {
BPropertyInfo propInfo(sPropList); BPropertyInfo propInfo(sPropList);
BHandler *target = NULL; BHandler *target = NULL;
@@ -812,8 +809,8 @@ BMenu::GetSupportedSuites(BMessage *data)
if (err < B_OK) if (err < B_OK)
return err; return err;
BPropertyInfo prop_info(sPropList); BPropertyInfo propertyInfo(sPropList);
err = data->AddFlat("messages", &prop_info); err = data->AddFlat("messages", &propertyInfo);
if (err < B_OK) if (err < B_OK)
return err; return err;
@@ -974,12 +971,9 @@ BMenu::AddDynamicItem(add_state s)
void void
BMenu::DrawBackground(BRect update) BMenu::DrawBackground(BRect update)
{ {
BRect rect = Bounds() & update;
rgb_color oldColor = HighColor(); rgb_color oldColor = HighColor();
SetHighColor(sMenuInfo.background_color); SetHighColor(sMenuInfo.background_color);
FillRect(rect, B_SOLID_HIGH); FillRect(Bounds() & update, B_SOLID_HIGH);
SetHighColor(oldColor); SetHighColor(oldColor);
} }
@@ -1096,12 +1090,8 @@ BMenu::_track(int *action, long start)
if (item != NULL) { if (item != NULL) {
if (item != fSelected) if (item != fSelected)
SelectItem(item); SelectItem(item);
} else if (fSelected != NULL) { } else if (fSelected != NULL && !OverSubmenu(fSelected, ConvertToScreen(location)))
BPoint screenLocation = location;
ConvertToScreen(&screenLocation);
if (!OverSubmenu(fSelected, screenLocation))
SelectItem(NULL); SelectItem(NULL);
}
if (fSelected != NULL && fSelected->Submenu() != NULL) { if (fSelected != NULL && fSelected->Submenu() != NULL) {
UnlockLooper(); UnlockLooper();
@@ -1290,7 +1280,7 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
for (int32 i = 0; i < fItems.CountItems(); i++) for (int32 i = 0; i < fItems.CountItems(); i++)
ItemAt(i)->fBounds.right = frame.right; ItemAt(i)->fBounds.right = frame.right;
frame.right = (float)ceil(frame.right); frame.right = ceilf(frame.right);
frame.bottom--; frame.bottom--;
break; break;
} }
@@ -1300,7 +1290,7 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
font_height fh; font_height fh;
GetFontHeight(&fh); GetFontHeight(&fh);
frame = BRect(0.0f, 0.0f, 0.0f, frame = BRect(0.0f, 0.0f, 0.0f,
(float)ceil(fh.ascent) + (float)ceil(fh.descent) + fPad.top + fPad.bottom); ceilf(fh.ascent) + ceilf(fh.descent) + fPad.top + fPad.bottom);
for (int32 i = 0; i < fItems.CountItems(); i++) { for (int32 i = 0; i < fItems.CountItems(); i++) {
item = ItemAt(i); item = ItemAt(i);
@@ -1319,7 +1309,7 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
for (int32 i = 0; i < fItems.CountItems(); i++) for (int32 i = 0; i < fItems.CountItems(); i++)
ItemAt(i)->fBounds.bottom = frame.bottom; ItemAt(i)->fBounds.bottom = frame.bottom;
frame.right = (float)ceil(frame.right) + 8.0f; frame.right = ceilf(frame.right) + 8.0f;
break; break;
} }
@@ -1382,7 +1372,7 @@ BMenu::ScreenLocation()
BMenu *superMenu = Supermenu(); BMenu *superMenu = Supermenu();
BMenuItem *superItem = Superitem(); BMenuItem *superItem = Superitem();
if (superMenu == NULL && superItem == NULL) { if (superMenu == NULL || superItem == NULL) {
debugger("BMenu can't determine where to draw." debugger("BMenu can't determine where to draw."
"Override BMenu::ScreenLocation() to determine location."); "Override BMenu::ScreenLocation() to determine location.");
} }
@@ -1562,7 +1552,7 @@ BMenu::CacheFontInfo()
GetFontHeight(&fh); GetFontHeight(&fh);
fAscent = fh.ascent; fAscent = fh.ascent;
fDescent = fh.descent; fDescent = fh.descent;
fFontHeight = (float)ceil(fh.ascent + fh.descent + fh.leading); fFontHeight = ceilf(fh.ascent + fh.descent + fh.leading);
} }