Re: [AD] win32 allegro_exit() blocks on non-active Window |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> when i call allegro_exit() it blocks until its made the active window.
Which switch mode do you use? Does it make any difference to set
SWITCH_BACKGROUND just before exiting, assuming you have already called
set_gfx_mode(TEXT)?
> by the time i have started to exit my program, the window disappears and
> there is still some work to be done, but from the users point of view the
> window is gone and therefore the program shut (in the users
> view)..... now the user clicks on some other Windows program, but the
> allegro program continues until it gets to allegro_exit() where it blocks
> until its made the active window again. (by clicking its task in the task
> bar).
>
> why must it be the active window ?
Probably because a routine which blocks when the window is not active and the
switch mode is SWITCH_PAUSE has just been called.
> i have no idea what the real reason for it is, but here is what i have
> found so far...
>
> in exit_directx_window() in /allegro/src/win/wwnd.c
>
> i found this:
>
> /* destroy the window: we cannot directly use
> * DestroyWindow() because we are not running
> * in the same thread as that of the window.
> */
>
> PostMessage(allegro_wnd, msg_suicide, 0, 0);
>
> /* wait until the window thread ends */
> WaitForSingleObject(wnd_thread, INFINITE);
>
> -----
>
> idea: would using win32::PostThreadMessage() fix my problem ?
I don't think so. I think this would be equivalent to calling PostMessage().
> does the current code block because the allegro_wnd is switched out and
> therefore not processing its messages ?
Certainly not. We must (and do) process the messages when we are switched out
(even in SWITCH_PAUSE mode), otherwise the OS would freeze. You can verify
that with WinTop for example: the window thread wakes up when you move a
window over the switched out Allegro window.
> or does Windows not post the message into the allegro_wnd's queue while
> its not an active window ?
Neither.
> why does code in exit_directx_window() in /allegro/src/win/wwnd.c
>
> attempt to shutdown the allegro_wnd when i have already removed it by
> calling set_gfx_mode(TEXT)
The window is not destroyed when you call set_gfx_mode(TEXT) because it is
not created when you call set_gfx_mode(). It is created when you call
allegro_init() so allegro_exit() must destroy it.
> could this PostMessage() be avoided by checking if the allegro_wnd has
> been shutdown already by a call to set_gfx_mode(TEXT)
No, it is mandatory.
> ?? does set_gfx_mode(TEXT) attempt to DestroyWindow() if not, why not
Because we are under Windows! Every Win32 GUI application must have at least
one window alive, even if it is not displayed on the screen.
--
Eric Botcazou