From 26b5401027b198700ec4cdc99a619d5368609a88 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Wed, 14 Jul 2004 07:41:47 +0000 Subject: [PATCH] Added implementation of _set_menu_sem_() to Window.cpp (should it go to a different place ?), thus fixing the build (at least here, I hope I didn't forget anything else). Thanks to Bill Hayden for reporting and sorry again for the trouble. Changed a comment in PopUpMenu.cpp git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8394 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/PopUpMenu.cpp | 10 +++++++--- src/kits/interface/Window.cpp | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/kits/interface/PopUpMenu.cpp b/src/kits/interface/PopUpMenu.cpp index c0c0b763f9..08ebbdfd7a 100644 --- a/src/kits/interface/PopUpMenu.cpp +++ b/src/kits/interface/PopUpMenu.cpp @@ -21,6 +21,7 @@ // // File Name: PopUpMenu.cpp // Author: Marc Flerackers (mflerackers@androme.be) +// Stefano Ceccherini (burton666@libero.it) // Description: BPopUpMenu represents a menu that pops up when you // activate it. //------------------------------------------------------------------------------ @@ -297,9 +298,8 @@ BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened, popup_menu_data *data = new popup_menu_data; sem_id sem = create_sem(0, "window close lock"); - // Asynchronous menu: we set the BWindow semaphore - // and let BWindow do the job for us (??? this is what - // it's probably happening, _set_menu_sem_() is undocumented) + // Asynchronous menu: we set the BWindow menu's semaphore + // and let BWindow block when needed if (async) { data->window = window; _set_menu_sem_(window, sem); @@ -330,10 +330,14 @@ BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened, delete data; return NULL; } + // Synchronous menu: we block on the sem till // the other thread deletes it. if (!async) { if (window) { + // TODO: usually it's not a good idea to check for a particular error + // code. Though here we just want to wait till the semaphore is deleted + // (it will return B_BAD_SEM_ID in that case), not provide locking or whatever. while (acquire_sem_etc(sem, 1, B_TIMEOUT, 50000) != B_BAD_SEM_ID) window->UpdateIfNeeded(); } diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index e2986517e0..3f72ae9b25 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -127,6 +127,15 @@ static property_info windowPropInfo[] = }; //------------------------------------------------------------------------------ + +// TODO: Move this to a better place ? +void +_set_menu_sem_(BWindow *window, sem_id sem) +{ + window->fMenuSem = sem; +} + + // Constructors //------------------------------------------------------------------------------ BWindow::BWindow(BRect frame,