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.
This commit is contained in:
@@ -666,8 +666,9 @@ TExpandoMenuBar::AddTeam(team_id team, const char* signature)
|
|||||||
void
|
void
|
||||||
TExpandoMenuBar::RemoveTeam(team_id team, bool partial)
|
TExpandoMenuBar::RemoveTeam(team_id team, bool partial)
|
||||||
{
|
{
|
||||||
int32 count = CountItems();
|
TWindowMenuItem* windowItem = NULL;
|
||||||
for (int32 i = 0; i < count; i++) {
|
|
||||||
|
for (int32 i = 0; i < CountItems(); i++) {
|
||||||
if (TTeamMenuItem* item = dynamic_cast<TTeamMenuItem*>(ItemAt(i))) {
|
if (TTeamMenuItem* item = dynamic_cast<TTeamMenuItem*>(ItemAt(i))) {
|
||||||
if (item->Teams()->HasItem((void*)(addr_t)team)) {
|
if (item->Teams()->HasItem((void*)(addr_t)team)) {
|
||||||
item->Teams()->RemoveItem(team);
|
item->Teams()->RemoveItem(team);
|
||||||
@@ -680,10 +681,18 @@ TExpandoMenuBar::RemoveTeam(team_id team, bool partial)
|
|||||||
fLastClickItem = -1;
|
fLastClickItem = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
BAutolock locker(sMonLocker);
|
||||||
|
// make the update thread wait
|
||||||
RemoveItem(i);
|
RemoveItem(i);
|
||||||
|
delete item;
|
||||||
|
while ((windowItem = dynamic_cast<TWindowMenuItem*>(
|
||||||
|
ItemAt(i))) != NULL) {
|
||||||
|
// Also remove window items (if there are any)
|
||||||
|
RemoveItem(i);
|
||||||
|
delete windowItem;
|
||||||
|
}
|
||||||
SizeWindow(-1);
|
SizeWindow(-1);
|
||||||
Window()->UpdateIfNeeded();
|
Window()->UpdateIfNeeded();
|
||||||
delete item;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user