From: Peter W. <nov...@gm...> - 2012-12-22 22:32:09
|
On Thu, 20 Dec 2012 05:35:56 +0000, "Trent Gamblin" <tr...@us...> wrote: > This is an automated email from the git hooks/post-receive script. It was > generated because a ref change was pushed to the repository containing > the project "Allegro". > > The branch, 5.1 has been updated > via f8b0e3bde2b09a1fbe84ef21e003a887c4bb2b8c (commit) > from 88f365e6ed3552412a635eaf48afe6a41fb854ad (commit) > > Those revisions listed above that are new to this repository have > not appeared on any other notification email; so we list those > revisions in full, below. > > - Log ----------------------------------------------------------------- > commit f8b0e3bde2b09a1fbe84ef21e003a887c4bb2b8c > Author: Trent Gamblin <tr...@us...> > Date: Wed Dec 19 22:35:07 2012 -0700 > > Making variable volatile seems to stop hang in OS X native dialogs. > > ----------------------------------------------------------------------- > > Summary of changes: > addons/native_dialog/osx_dialog.m | 5 +++-- > 1 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/addons/native_dialog/osx_dialog.m b/addons/native_dialog/osx_dialog.m > index 01c9ab5..29feca2 100644 > --- a/addons/native_dialog/osx_dialog.m > +++ b/addons/native_dialog/osx_dialog.m > @@ -496,7 +496,7 @@ typedef struct DISPLAY_INFO { > > static _AL_VECTOR menus = _AL_VECTOR_INITIALIZER(ALLEGRO_MENU *); > static _AL_VECTOR displays = _AL_VECTOR_INITIALIZER(DISPLAY_INFO *); > -static ALLEGRO_EVENT_QUEUE *queue = NULL; > +static volatile ALLEGRO_EVENT_QUEUE *queue = NULL; > static ALLEGRO_MUTEX *mutex; > > #define add_menu(name, sel, eq) \ > @@ -580,7 +580,8 @@ static void ensure_event_thread(void) > > al_run_detached_thread(event_thread, NULL); > > - while (!queue); > + while (!queue) > + al_rest(0.001); > } I suggest creating the mutex and queue before starting the event_thread thread, then this dodgy loop should not be required, nor the volatile qualifier, nor casts to ALLEGRO_EVENT_QUEUE *. I'm uncomfortable with detached threads in general. If it's possible I suggest an explicit thread join, then you can destroy the queue and mutex afterwards, in a more controlled fashion. Peter |