Check the lock, some cleanups. Fixes some crashing bugs which didn't show up before for pure luck

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17418 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-05-10 20:15:36 +00:00
parent c8773f97a0
commit 1655525f95
3 changed files with 42 additions and 39 deletions

View File

@ -48,6 +48,7 @@ FontMenu::GetFonts()
}
}
void
FontMenu::Update()
{
@ -55,23 +56,28 @@ FontMenu::Update()
// related stuff out of the FontMenu class
// so it can be easily reused in other apps
get_menu_info(&info);
// font menu
BFont font;
font.SetFamilyAndStyle(info.f_family, info.f_style);
font.SetSize(info.font_size);
SetFont(&font);
SetViewColor(info.background_color);
InvalidateLayout();
// font style menus
for (int i = 0; i < CountItems(); i++) {
ItemAt(i)->Submenu()->SetFont(&font);
}
if (LockLooper()) {
SetFont(&font);
SetViewColor(info.background_color);
// font style menus
for (int i = 0; i < CountItems(); i++)
ItemAt(i)->Submenu()->SetFont(&font);
InvalidateLayout();
Invalidate();
UnlockLooper();
}
ClearAllMarkedItems();
PlaceCheckMarkOnFont(info.f_family, info.f_style);
}
status_t
FontMenu::PlaceCheckMarkOnFont(font_family family, font_style style)
{
@ -80,24 +86,18 @@ FontMenu::PlaceCheckMarkOnFont(font_family family, font_style style)
BMenu *styleMenu;
fontFamilyItem = FindItem(family);
if ((fontFamilyItem != NULL) && (family != NULL))
{
if ((fontFamilyItem != NULL) && (family != NULL)) {
fontFamilyItem->SetMarked(true);
styleMenu = fontFamilyItem->Submenu();
if ((styleMenu != NULL) && (style != NULL))
{
if ((styleMenu != NULL) && (style != NULL)) {
fontStyleItem = styleMenu->FindItem(style);
if (fontStyleItem != NULL)
{
fontStyleItem->SetMarked(true);
}
}
else
} else
return B_ERROR;
}
else
} else
return B_ERROR;
return B_OK;

View File

@ -57,15 +57,15 @@ FontSizeMenu::Update()
get_menu_info(&info);
BFont font;
Supermenu()->Window()->Lock();
font.SetFamilyAndStyle(info.f_family, info.f_style);
font.SetSize(info.font_size);
SetFont(&font);
SetViewColor(info.background_color);
Supermenu()->Window()->Unlock();
set_menu_info(&info);
InvalidateLayout();
Invalidate();
if (LockLooper()) {
font.SetFamilyAndStyle(info.f_family, info.f_style);
font.SetSize(info.font_size);
SetFont(&font);
SetViewColor(info.background_color);
InvalidateLayout();
Invalidate();
UnlockLooper();
}
SetEnabled(true);
}

View File

@ -131,15 +131,17 @@ MenuBar::Update()
set_menu();
BFont font;
Window()->Lock();
font.SetFamilyAndStyle(info.f_family, info.f_style);
font.SetSize(info.font_size);
SetFont(&font);
SetViewColor(info.background_color);
Window()->Unlock();
// force the menu to redraw
InvalidateLayout();
if (LockLooper()) {
font.SetFamilyAndStyle(info.f_family, info.f_style);
font.SetSize(info.font_size);
SetFont(&font);
SetViewColor(info.background_color);
// force the menu to redraw
InvalidateLayout();
Invalidate();
UnlockLooper();
}
}
@ -147,5 +149,6 @@ void
MenuBar::FrameResized(float width, float height)
{
Window()->ResizeTo(width + 80, height + 55);
Window()->PostMessage(UPDATE_WINDOW);
Window()->PostMessage(UPDATE_WINDOW);
BMenuBar::FrameResized(width, height);
}