From 733be65954f85c0c0cd57d0bec95d8a47f9d1f4a Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sun, 24 Feb 2013 04:30:41 -0500 Subject: [PATCH] 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. --- src/apps/deskbar/ExpandoMenuBar.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 21fbcffb02..07509971c0 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);