Mercurial > mplayer.hg
changeset 33307:552f1f7731c8
Set GUI initialization flag earlier.
So far, the flag is set after the call of guiInit(), but there are calls
to GUI functions (like reading the GUI config) before that. As MPlayer
(when exiting) only calls GUI's cleanup function guiDone() if the flag
is set, it neglects calling guiDone() on any error between the first GUI
function call and execution of guiInit(). Now the flag is set before the
first GUI function call.
As a result, GUI's own exit function (also used for fatal GUI errors, and
thus also for errors occurring before guiInit() properly finishes) doesn't
have to handle cleanup any longer. The code can be moved to guiDone().
author | ib |
---|---|
date | Sat, 07 May 2011 15:30:14 +0000 |
parents | 37e215798390 |
children | 0c2f2368a031 |
files | gui/interface.c mplayer.c |
diffstat | 2 files changed, 13 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/interface.c Sat May 07 11:11:07 2011 +0000 +++ b/gui/interface.c Sat May 07 15:30:14 2011 +0000 @@ -52,8 +52,6 @@ #include "stream/stream_dvd.h" #endif -#define DONE -1 - guiInterface_t guiIntfStruct; int guiWinID = -1; @@ -385,6 +383,7 @@ void guiDone(void) { + if (initialized) { mplMainRender = 0; mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] done.\n"); @@ -405,31 +404,19 @@ cfg_write(); wsXDone(); + } - guiExit(DONE); + appFreeStruct(); + + if (gui_conf) { + m_config_free(gui_conf); + gui_conf = NULL; + } } -// NOTE TO MYSELF: Before calling guiInit(), MPlayer calls GUI functions -// cfg_read() and import_initial_playtree_into_gui(). Only -// after guiInit() has been called successfully, guiDone() -// (and thus guiExit()) will be executed by MPlayer on exit. -// In other words, any MPlayer's exit between cfg_read() and -// guiInit() will not execute guiDone(). -// With this function it is at least possible to handle -// GUI's own abortions during (and before) guiInit(). void guiExit(int how) { - if (!initialized || (how == DONE)) { - if (gui_conf) { - m_config_free(gui_conf); - gui_conf = NULL; - } - - appFreeStruct(); - } - - if (how != DONE) - exit_player_with_rc(how, how >= EXIT_ERROR); + exit_player_with_rc(how, how >= EXIT_ERROR); } void guiLoadFont(void)
--- a/mplayer.c Sat May 07 11:11:07 2011 +0000 +++ b/mplayer.c Sat May 07 15:30:14 2011 +0000 @@ -2757,7 +2757,10 @@ parse_cfgfiles(mconfig); #ifdef CONFIG_GUI - if ( use_gui ) cfg_read(); + if ( use_gui ) { + initialized_flags|=INITIALIZED_GUI; + cfg_read(); + } #endif mpctx->playtree = m_config_parse_mp_command_line(mconfig, argc, argv); @@ -3018,7 +3021,6 @@ if(use_gui){ guiInit(); guiGetEvent(guiSetContext, mpctx); - initialized_flags|=INITIALIZED_GUI; guiGetEvent( guiCEvent,(char *)((gui_no_filename) ? 0 : 1) ); } #endif