From 9bc3b671fb63b89ea766bc7a5330f71cea8378c3 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sat, 6 Apr 2013 21:58:14 -0400 Subject: [PATCH] Fix a bug involving the Vulcan Death Grip closing the wrong app If you have expander turned on with expanded apps and you quickly remove teams with the VDG you can remove a team not under your mouse pointer, instead you remote the team above. This is because the window watcher thread hasn't updated yet so the TeamItemAtPoint() method reads a window menu item instead of the team item. The solution is to lock the window watcher thread and explicitly remove the window menu items in RemoveTeam(). This bug can be really bad if you accidentially VDG Tracker as your system gets hosed until you restart Tracker or reboot. --- src/apps/deskbar/ExpandoMenuBar.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 8c60fbe1bc..d052203bea 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -666,8 +666,9 @@ TExpandoMenuBar::AddTeam(team_id team, const char* signature) void TExpandoMenuBar::RemoveTeam(team_id team, bool partial) { - int32 count = CountItems(); - for (int32 i = 0; i < count; i++) { + TWindowMenuItem* windowItem = NULL; + + for (int32 i = 0; i < CountItems(); i++) { if (TTeamMenuItem* item = dynamic_cast(ItemAt(i))) { if (item->Teams()->HasItem((void*)(addr_t)team)) { item->Teams()->RemoveItem(team); @@ -680,10 +681,18 @@ TExpandoMenuBar::RemoveTeam(team_id team, bool partial) fLastClickItem = -1; #endif + BAutolock locker(sMonLocker); + // make the update thread wait RemoveItem(i); + delete item; + while ((windowItem = dynamic_cast( + ItemAt(i))) != NULL) { + // Also remove window items (if there are any) + RemoveItem(i); + delete windowItem; + } SizeWindow(-1); Window()->UpdateIfNeeded(); - delete item; return; } }