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:
parent
c8773f97a0
commit
1655525f95
@ -48,6 +48,7 @@ FontMenu::GetFonts()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FontMenu::Update()
|
FontMenu::Update()
|
||||||
{
|
{
|
||||||
@ -55,23 +56,28 @@ FontMenu::Update()
|
|||||||
// related stuff out of the FontMenu class
|
// related stuff out of the FontMenu class
|
||||||
// so it can be easily reused in other apps
|
// so it can be easily reused in other apps
|
||||||
get_menu_info(&info);
|
get_menu_info(&info);
|
||||||
|
|
||||||
// font menu
|
// font menu
|
||||||
BFont font;
|
BFont font;
|
||||||
font.SetFamilyAndStyle(info.f_family, info.f_style);
|
font.SetFamilyAndStyle(info.f_family, info.f_style);
|
||||||
font.SetSize(info.font_size);
|
font.SetSize(info.font_size);
|
||||||
SetFont(&font);
|
|
||||||
SetViewColor(info.background_color);
|
if (LockLooper()) {
|
||||||
InvalidateLayout();
|
SetFont(&font);
|
||||||
// font style menus
|
SetViewColor(info.background_color);
|
||||||
for (int i = 0; i < CountItems(); i++) {
|
// font style menus
|
||||||
ItemAt(i)->Submenu()->SetFont(&font);
|
for (int i = 0; i < CountItems(); i++)
|
||||||
}
|
ItemAt(i)->Submenu()->SetFont(&font);
|
||||||
|
InvalidateLayout();
|
||||||
|
Invalidate();
|
||||||
|
UnlockLooper();
|
||||||
|
}
|
||||||
|
|
||||||
ClearAllMarkedItems();
|
ClearAllMarkedItems();
|
||||||
PlaceCheckMarkOnFont(info.f_family, info.f_style);
|
PlaceCheckMarkOnFont(info.f_family, info.f_style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
FontMenu::PlaceCheckMarkOnFont(font_family family, font_style style)
|
FontMenu::PlaceCheckMarkOnFont(font_family family, font_style style)
|
||||||
{
|
{
|
||||||
@ -80,24 +86,18 @@ FontMenu::PlaceCheckMarkOnFont(font_family family, font_style style)
|
|||||||
BMenu *styleMenu;
|
BMenu *styleMenu;
|
||||||
|
|
||||||
fontFamilyItem = FindItem(family);
|
fontFamilyItem = FindItem(family);
|
||||||
if ((fontFamilyItem != NULL) && (family != NULL))
|
if ((fontFamilyItem != NULL) && (family != NULL)) {
|
||||||
{
|
|
||||||
fontFamilyItem->SetMarked(true);
|
fontFamilyItem->SetMarked(true);
|
||||||
styleMenu = fontFamilyItem->Submenu();
|
styleMenu = fontFamilyItem->Submenu();
|
||||||
|
|
||||||
if ((styleMenu != NULL) && (style != NULL))
|
if ((styleMenu != NULL) && (style != NULL)) {
|
||||||
{
|
|
||||||
fontStyleItem = styleMenu->FindItem(style);
|
fontStyleItem = styleMenu->FindItem(style);
|
||||||
if (fontStyleItem != NULL)
|
if (fontStyleItem != NULL)
|
||||||
{
|
|
||||||
fontStyleItem->SetMarked(true);
|
fontStyleItem->SetMarked(true);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
@ -57,15 +57,15 @@ FontSizeMenu::Update()
|
|||||||
get_menu_info(&info);
|
get_menu_info(&info);
|
||||||
BFont font;
|
BFont font;
|
||||||
|
|
||||||
Supermenu()->Window()->Lock();
|
if (LockLooper()) {
|
||||||
font.SetFamilyAndStyle(info.f_family, info.f_style);
|
font.SetFamilyAndStyle(info.f_family, info.f_style);
|
||||||
font.SetSize(info.font_size);
|
font.SetSize(info.font_size);
|
||||||
SetFont(&font);
|
SetFont(&font);
|
||||||
SetViewColor(info.background_color);
|
SetViewColor(info.background_color);
|
||||||
Supermenu()->Window()->Unlock();
|
InvalidateLayout();
|
||||||
set_menu_info(&info);
|
Invalidate();
|
||||||
|
UnlockLooper();
|
||||||
InvalidateLayout();
|
}
|
||||||
Invalidate();
|
|
||||||
SetEnabled(true);
|
SetEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -131,15 +131,17 @@ MenuBar::Update()
|
|||||||
set_menu();
|
set_menu();
|
||||||
|
|
||||||
BFont font;
|
BFont font;
|
||||||
Window()->Lock();
|
if (LockLooper()) {
|
||||||
font.SetFamilyAndStyle(info.f_family, info.f_style);
|
font.SetFamilyAndStyle(info.f_family, info.f_style);
|
||||||
font.SetSize(info.font_size);
|
font.SetSize(info.font_size);
|
||||||
SetFont(&font);
|
SetFont(&font);
|
||||||
SetViewColor(info.background_color);
|
SetViewColor(info.background_color);
|
||||||
Window()->Unlock();
|
|
||||||
|
// force the menu to redraw
|
||||||
// force the menu to redraw
|
InvalidateLayout();
|
||||||
InvalidateLayout();
|
Invalidate();
|
||||||
|
UnlockLooper();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -147,5 +149,6 @@ void
|
|||||||
MenuBar::FrameResized(float width, float height)
|
MenuBar::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
Window()->ResizeTo(width + 80, height + 55);
|
Window()->ResizeTo(width + 80, height + 55);
|
||||||
Window()->PostMessage(UPDATE_WINDOW);
|
Window()->PostMessage(UPDATE_WINDOW);
|
||||||
|
BMenuBar::FrameResized(width, height);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user