hrev45321 adds 3 changesets to branch 'master' old head: e8d6e3fe3b85f88fe9506257b0cbbf5341a3a840 new head: 733be65954f85c0c0cd57d0bec95d8a47f9d1f4a overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=733be65+%5Ee8d6e3f ---------------------------------------------------------------------------- da17915: Small whitespace fix in MenuBar.cpp 88571c9: Refactor TExpandoMenuBar::MouseDown() style. No functional change intended. * Check for NULL fields in the beginning and return decreasing the indent level of the rest of the method. * Move some comments to next line indented 733be65: Prevent a deadlock condition in Deskbar. Fixes #8539 If the window is locked by the menu_tracking thread Deskbar will wait on the sMonThread thread to exit forever so we have to kill it to prevent a deadlock. This is a workaround of a bigger problem, which is that fExpando gets created and destroyed on each change which is slow allowing these kinds of bugs to exist. The real solution is to live update fExpando but that is a fair amount of work. [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 2 files changed, 63 insertions(+), 56 deletions(-) src/apps/deskbar/ExpandoMenuBar.cpp | 108 +++++++++++++++++--------------- src/kits/interface/MenuBar.cpp | 11 ++-- ############################################################################ Commit: da179153e88c93913ca46b8bc4c80646fa23a00b URL: http://cgit.haiku-os.org/haiku/commit/?id=da17915 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Feb 24 07:00:51 2013 UTC Small whitespace fix in MenuBar.cpp ---------------------------------------------------------------------------- diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index b29f9d5..8c7dc13 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -340,9 +340,9 @@ BMenuBar::MouseDown(BPoint where) uint32 buttons; GetMouse(&where, &buttons); - - BWindow* window = Window(); - if (!window->IsActive() || !window->IsFront()) { + + BWindow* window = Window(); + if (!window->IsActive() || !window->IsFront()) { if ((mouse_mode() == B_FOCUS_FOLLOWS_MOUSE) || ((mouse_mode() == B_CLICK_TO_FOCUS_MOUSE) && ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0))) { @@ -500,8 +500,8 @@ BMenuBar::StartMenuBar(int32 menuIndex, bool sticky, bool showMenu, fMenuSem = create_sem(0, "window close sem"); _set_menu_sem_(window, fMenuSem); - fTrackingPID = spawn_thread(_TrackTask, "menu_tracking", B_DISPLAY_PRIORITY, - NULL); + fTrackingPID = spawn_thread(_TrackTask, "menu_tracking", + B_DISPLAY_PRIORITY, NULL); if (fTrackingPID >= 0) { menubar_data data; data.menuBar = this; @@ -699,7 +699,6 @@ BMenuBar::_Track(int32* action, int32 startIndex, bool showMenu) *action = fState; return fChosenItem; - } ############################################################################ Commit: 88571c92411f8980452f719c6456bd475d7db5a4 URL: http://cgit.haiku-os.org/haiku/commit/?id=88571c9 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Feb 24 07:18:20 2013 UTC Refactor TExpandoMenuBar::MouseDown() style. No functional change intended. * Check for NULL fields in the beginning and return decreasing the indent level of the rest of the method. * Move some comments to next line indented ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 310d5ab..21fbcff 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -337,66 +337,66 @@ TExpandoMenuBar::MouseDown(BPoint where) BMenuItem* menuItem; TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem); - // check for three finger salute, a.k.a. Vulcan Death Grip - if (message != NULL && item != NULL && !fBarView->Dragging()) { - int32 modifiers = 0; - message->FindInt32("modifiers", &modifiers); - - if ((modifiers & B_COMMAND_KEY) != 0 - && (modifiers & B_CONTROL_KEY) != 0 - && (modifiers & B_SHIFT_KEY) != 0) { - const BList* teams = item->Teams(); - int32 teamCount = teams->CountItems(); - - team_id teamID; - for (int32 team = 0; team < teamCount; team++) { - teamID = (addr_t)teams->ItemAt(team); - kill_team(teamID); - // remove the team immediately from display - RemoveTeam(teamID, false); - } + if (message == NULL || item == NULL || fBarView->Dragging()) { + BMenuBar::MouseDown(where); + return; + } - return; - } + int32 modifiers = 0; + message->FindInt32("modifiers", &modifiers); - // control click - show all/hide all shortcut - if ((modifiers & B_CONTROL_KEY) != 0) { - // show/hide item's teams - BMessage showMessage((modifiers & B_SHIFT_KEY) != 0 - ? kMinimizeTeam : kBringTeamToFront); - showMessage.AddInt32("itemIndex", IndexOf(item)); - Window()->PostMessage(&showMessage, this); - return; + // check for three finger salute, a.k.a. Vulcan Death Grip + if ((modifiers & B_COMMAND_KEY) != 0 + && (modifiers & B_CONTROL_KEY) != 0 + && (modifiers & B_SHIFT_KEY) != 0) { + const BList* teams = item->Teams(); + int32 teamCount = teams->CountItems(); + team_id teamID; + for (int32 team = 0; team < teamCount; team++) { + teamID = (addr_t)teams->ItemAt(team); + kill_team(teamID); + RemoveTeam(teamID, false); + // remove the team from display immediately } + return; + // absorb the message + } - // Check the bounds of the expand Team icon - if (fShowTeamExpander && fVertical) { - BRect expanderRect = item->ExpanderBounds(); - if (expanderRect.Contains(where)) { - // Let the update thread wait... - BAutolock locker(sMonLocker); - - // Toggle the item - item->ToggleExpandState(true); - item->Draw(); - - // Absorb the message. - return; - } - } + // control click - show all/hide all shortcut + if ((modifiers & B_CONTROL_KEY) != 0) { + // show/hide item's teams + BMessage showMessage((modifiers & B_SHIFT_KEY) != 0 + ? kMinimizeTeam : kBringTeamToFront); + showMessage.AddInt32("itemIndex", IndexOf(item)); + Window()->PostMessage(&showMessage, this); + return; + // absorb the message + } - // double-click on an item brings the team to front - int32 clicks; - if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1 - && item == menuItem && item == fLastClickItem) { - // activate this team - be_roster->ActivateApp((addr_t)item->Teams()->ItemAt(0)); + // Check the bounds of the expand Team icon + if (fVertical && fShowTeamExpander) { + if (item->ExpanderBounds().Contains(where)) { + BAutolock locker(sMonLocker); + // let the update thread wait... + item->ToggleExpandState(true); + // toggle the item + item->Draw(); return; + // absorb the message } + } - fLastClickItem = item; + // double-click on an item brings the team to front + int32 clicks; + if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1 + && item == menuItem && item == fLastClickItem) { + be_roster->ActivateApp((addr_t)item->Teams()->ItemAt(0)); + // activate this team + return; + // absorb the message } + fLastClickItem = item; BMenuBar::MouseDown(where); } ############################################################################ Revision: hrev45321 Commit: 733be65954f85c0c0cd57d0bec95d8a47f9d1f4a URL: http://cgit.haiku-os.org/haiku/commit/?id=733be65 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Feb 24 09:30:41 2013 UTC Ticket: https://dev.haiku-os.org/ticket/8539 Prevent a deadlock condition in Deskbar. Fixes #8539 If the window is locked by the menu_tracking thread Deskbar will wait on the sMonThread thread to exit forever so we have to kill it to prevent a deadlock. This is a workaround of a bigger problem, which is that fExpando gets created and destroyed on each change which is slow allowing these kinds of bugs to exist. The real solution is to live update fExpando but that is a fair amount of work. ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 21fbcff..0750997 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -195,6 +195,14 @@ TExpandoMenuBar::DetachedFromWindow() if (sMonThread != B_ERROR) { sDoMonitor = false; + if (Window()->IsLocked()) { + // If window is locked by the menu_tracking thread kill it + // to prevent a deadlock. See ticket #8539. + thread_id menu_tracking = find_thread("menu_tracking"); + if (menu_tracking != B_NAME_NOT_FOUND) + kill_thread(menu_tracking); + } + status_t returnCode; wait_for_thread(sMonThread, &returnCode);