diff --git a/src/kits/interface/PopUpMenu.cpp b/src/kits/interface/PopUpMenu.cpp index a1028d8d4e..6a9515b10b 100644 --- a/src/kits/interface/PopUpMenu.cpp +++ b/src/kits/interface/PopUpMenu.cpp @@ -371,12 +371,12 @@ BPopUpMenu::entry(void *arg) data->selected = menu->start_track(where, autoInvoke, startOpened, rect); - delete_sem(data->lock); - // Reset the window menu semaphore if (data->async && data->window) _set_menu_sem_(data->window, B_BAD_SEM_ID); + delete_sem(data->lock); + // Commit suicide if needed if (menu->fAutoDestruct) delete menu; diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 96ae44abf8..828469bfa6 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -316,6 +316,12 @@ BWindow::~BWindow() { Lock(); + // Wait if a menu is still tracking + if (fMenuSem > 0) { + while (acquire_sem(fMenuSem) == B_INTERRUPTED) + ; + } + fTopView->RemoveSelf(); delete fTopView; @@ -328,10 +334,6 @@ BWindow::~BWindow() // TODO: release other dynamically-allocated objects free(fTitle); - // Deleting this semaphore will tell open menus to quit. - if (fMenuSem > 0) - delete_sem(fMenuSem); - // disable pulsing SetPulseRate(0);