Tracker: Bail out before cleanup if popup window is already open

Fixes crashes & irregularities when context-clicking repeatedly,
especially on Desktop.

Remove RepopulateMenus() context-clicking on Desktop introduced
in hrev44673.

Fixes #15890

Change-Id: I373d78e4fd0533d248c6cfd4291f6f69f212a6c4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8374
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
This commit is contained in:
John Scipione 2024-09-26 16:50:20 -04:00 committed by waddlesplash
parent 77fafacae3
commit f2dca4f0f6

View File

@ -2655,6 +2655,10 @@ BContainerWindow::ShowContextMenu(BPoint where, const entry_ref* ref)
if (fContextMenu == NULL)
return;
// bail out before cleanup if popup window is already open
if (fContextMenu->Window() != NULL)
return;
// clean up items from last context menu
MenusEnded();
@ -2693,18 +2697,21 @@ BContainerWindow::ShowContextMenu(BPoint where, const entry_ref* ref)
UpdateMenu(fContextMenu, kPosePopUpContext);
}
} else if (fWindowContextMenu != NULL) {
// Repopulate desktop menu
if (PoseView()->IsDesktop())
RepopulateMenus();
// clicked on a window, show window context menu
fContextMenu = fWindowContextMenu;
// bail out before cleanup if popup window is already open
if (fContextMenu->Window() != NULL)
return;
// clean up items from last context menu
MenusEnded();
// clicked on a window, show window context menu
// setup nav menu
SetupNavigationMenu(TargetModel()->EntryRef(), fContextMenu);
SetupNavigationMenu(ref, fWindowContextMenu);
UpdateMenu(fWindowContextMenu, kWindowPopUpContext);
fContextMenu = fWindowContextMenu;
// update the rest
UpdateMenu(fContextMenu, kWindowPopUpContext);
}
// context menu invalid or popup window is already open