* only delete the popupmenu if we running the async version of BPopUpMenu
This fixes part 3 of task #1987, TaskManager was using the syncronous version of of BPopUpMenu wrapped in it's own class to run asyncronous. It did set SetAsyncAutoDestruct to true and afterwards calling delete an the already deleted menu. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26406 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -63,7 +63,7 @@ BPopUpMenu::~BPopUpMenu()
|
|||||||
if (fTrackThread >= 0) {
|
if (fTrackThread >= 0) {
|
||||||
status_t status;
|
status_t status;
|
||||||
while (wait_for_thread(fTrackThread, &status) == B_INTERRUPTED)
|
while (wait_for_thread(fTrackThread, &status) == B_INTERRUPTED)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
|
|||||||
sem_id sem = create_sem(0, "window close lock");
|
sem_id sem = create_sem(0, "window close lock");
|
||||||
if (sem < B_OK) {
|
if (sem < B_OK) {
|
||||||
delete data;
|
delete data;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a pointer to the window from which Go() was called
|
// Get a pointer to the window from which Go() was called
|
||||||
@@ -284,7 +284,7 @@ BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
|
|||||||
// and let BWindow block when needed
|
// and let BWindow block when needed
|
||||||
if (async && window != NULL) {
|
if (async && window != NULL) {
|
||||||
_set_menu_sem_(window, sem);
|
_set_menu_sem_(window, sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
data->object = this;
|
data->object = this;
|
||||||
data->autoInvoke = autoInvoke;
|
data->autoInvoke = autoInvoke;
|
||||||
@@ -298,7 +298,7 @@ BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
|
|||||||
data->lock = sem;
|
data->lock = sem;
|
||||||
|
|
||||||
// Spawn the tracking thread
|
// Spawn the tracking thread
|
||||||
fTrackThread = spawn_thread(_thread_entry, "popup", B_DISPLAY_PRIORITY, data);
|
fTrackThread = spawn_thread(_thread_entry, "popup", B_DISPLAY_PRIORITY, data);
|
||||||
if (fTrackThread < B_OK) {
|
if (fTrackThread < B_OK) {
|
||||||
// Something went wrong. Cleanup and return NULL
|
// Something went wrong. Cleanup and return NULL
|
||||||
delete_sem(sem);
|
delete_sem(sem);
|
||||||
@@ -322,22 +322,22 @@ int32
|
|||||||
BPopUpMenu::_thread_entry(void *arg)
|
BPopUpMenu::_thread_entry(void *arg)
|
||||||
{
|
{
|
||||||
popup_menu_data *data = static_cast<popup_menu_data *>(arg);
|
popup_menu_data *data = static_cast<popup_menu_data *>(arg);
|
||||||
BPopUpMenu *menu = data->object;
|
BPopUpMenu *menu = data->object;
|
||||||
BRect *rect = NULL;
|
BRect *rect = NULL;
|
||||||
|
|
||||||
if (data->useRect)
|
if (data->useRect)
|
||||||
rect = &data->rect;
|
rect = &data->rect;
|
||||||
|
|
||||||
data->selected = menu->_StartTrack(data->where, data->autoInvoke, data->startOpened, rect);
|
data->selected = menu->_StartTrack(data->where, data->autoInvoke, data->startOpened, rect);
|
||||||
|
|
||||||
// Reset the window menu semaphore
|
// Reset the window menu semaphore
|
||||||
if (data->async && data->window)
|
if (data->async && data->window)
|
||||||
_set_menu_sem_(data->window, B_BAD_SEM_ID);
|
_set_menu_sem_(data->window, B_BAD_SEM_ID);
|
||||||
|
|
||||||
delete_sem(data->lock);
|
delete_sem(data->lock);
|
||||||
|
|
||||||
// Commit suicide if needed
|
// Commit suicide if needed
|
||||||
if (menu->fAutoDestruct) {
|
if (data->async && menu->fAutoDestruct) {
|
||||||
menu->fTrackThread = -1;
|
menu->fTrackThread = -1;
|
||||||
delete menu;
|
delete menu;
|
||||||
}
|
}
|
||||||
@@ -388,13 +388,13 @@ BPopUpMenu::_WaitMenu(void *_data)
|
|||||||
status_t unused;
|
status_t unused;
|
||||||
while (wait_for_thread(fTrackThread, &unused) == B_INTERRUPTED)
|
while (wait_for_thread(fTrackThread, &unused) == B_INTERRUPTED)
|
||||||
;
|
;
|
||||||
|
|
||||||
fTrackThread = -1;
|
fTrackThread = -1;
|
||||||
|
|
||||||
BMenuItem *selected = data->selected;
|
BMenuItem *selected = data->selected;
|
||||||
// data->selected is filled by the tracking thread
|
// data->selected is filled by the tracking thread
|
||||||
|
|
||||||
delete data;
|
delete data;
|
||||||
|
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user