[MPlayer-cvslog] r33350 - in trunk/gui: interface.c interface.h mplayer/mw.c mplayer/pb.c mplayer/sw.c

ib subversion at mplayerhq.hu
Tue May 3 14:19:23 CEST 2011


Author: ib
Date: Tue May  3 14:19:22 2011
New Revision: 33350

Log:
Add an exit function.

This function will allow performing clean-up operations.

(MPlayer calls guiDone() before exiting, but only if the GUI has been
initialized, i.e. if guiInit() has been called successfully. Any
exit_player()/exit_player_with_rc() after GUI's cfg_read() until
guiInit(), or any exit_player() during guiInit() itself will end the GUI
without calling guiDone(). This exit function will at least handle
abortions during guiInit() itself. It will be called twice in case of an
guiExit() after GUI initialization - first directly, next by guiDone()
via MPlayer's exit_player_with_rc().)

Modified:
   trunk/gui/interface.c
   trunk/gui/interface.h
   trunk/gui/mplayer/mw.c
   trunk/gui/mplayer/pb.c
   trunk/gui/mplayer/sw.c

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Tue May  3 11:51:59 2011	(r33349)
+++ trunk/gui/interface.c	Tue May  3 14:19:22 2011	(r33350)
@@ -52,6 +52,8 @@
 #include "stream/stream_dvd.h"
 #endif
 
+#define DONE -1
+
 guiInterface_t guiIntfStruct;
 
 int guiWinID = -1;
@@ -220,11 +222,11 @@ void guiInit(void)
     switch (i) {
     case -1:
         gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SKINCFG_SkinNotFound, skinName);
-        exit_player(EXIT_ERROR);
+        guiExit(EXIT_ERROR);
 
     case -2:
         gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SKINCFG_SkinCfgError, skinName);
-        exit_player(EXIT_ERROR);
+        guiExit(EXIT_ERROR);
     }
 
     // initialize windows
@@ -233,7 +235,7 @@ void guiInit(void)
 
     if (!mplDrawBuffer) {
         gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB);
-        exit_player(EXIT_ERROR);
+        guiExit(EXIT_ERROR);
     }
 
     if (gui_save_pos) {
@@ -401,6 +403,22 @@ void guiDone(void)
 
     cfg_write();
     wsXDone();
+
+    guiExit(DONE);
+}
+
+// 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 (how != DONE)
+        exit_player(how);
 }
 
 void guiLoadFont(void)
@@ -852,7 +870,7 @@ int guiGetEvent(int type, void *arg)
 
         if (!video_driver_list && !video_driver_list[0]) {
             gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_IDFGCVD);
-            exit_player(EXIT_ERROR);
+            guiExit(EXIT_ERROR);
         }
 
         {

Modified: trunk/gui/interface.h
==============================================================================
--- trunk/gui/interface.h	Tue May  3 11:51:59 2011	(r33349)
+++ trunk/gui/interface.h	Tue May  3 14:19:22 2011	(r33350)
@@ -239,6 +239,7 @@ char *gstrdup(const char *str);
 void *gtkSet(int cmd, float fparam, void *vparam);
 void guiDone(void);
 void guiEventHandling(void);
+void guiExit(int how);
 int guiGetEvent(int type, void *arg);
 void guiInit(void);
 void guiLoadFont(void);

Modified: trunk/gui/mplayer/mw.c
==============================================================================
--- trunk/gui/mplayer/mw.c	Tue May  3 11:51:59 2011	(r33349)
+++ trunk/gui/mplayer/mw.c	Tue May  3 14:19:22 2011	(r33350)
@@ -75,7 +75,7 @@ int             i,pot = 0;
 void mplMainDraw( void )
 {
 
- if ( appMPlayer.mainWindow.State == wsWindowClosed ) exit_player( EXIT_QUIT );
+ if ( appMPlayer.mainWindow.State == wsWindowClosed ) guiExit( EXIT_QUIT );
 
  if ( appMPlayer.mainWindow.Visible == wsWindowNotVisible ||
       !mainVisible ) return;
@@ -105,7 +105,7 @@ void mplEventHandling( int msg,float par
   {
 // --- user events
    case evExit:
-        exit_player( EXIT_QUIT );
+        guiExit( EXIT_QUIT );
         break;
 
    case evPlayNetwork:

Modified: trunk/gui/mplayer/pb.c
==============================================================================
--- trunk/gui/mplayer/pb.c	Tue May  3 11:51:59 2011	(r33349)
+++ trunk/gui/mplayer/pb.c	Tue May  3 14:19:22 2011	(r33350)
@@ -247,7 +247,7 @@ void mplPBInit( void )
  if ( ( mplPBDrawBuffer = malloc( appMPlayer.bar.Bitmap.ImageSize ) ) == NULL )
   {
    gmp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_NEMDB );
-   exit_player( EXIT_ERROR );
+   guiExit( EXIT_ERROR );
   }
 
  appMPlayer.barWindow.Parent=appMPlayer.subWindow.WindowID;

Modified: trunk/gui/mplayer/sw.c
==============================================================================
--- trunk/gui/mplayer/sw.c	Tue May  3 11:51:59 2011	(r33349)
+++ trunk/gui/mplayer/sw.c	Tue May  3 14:19:22 2011	(r33350)
@@ -35,7 +35,7 @@ int             SubVisible = 0;
 
 void mplSubDraw( void )
 {
- if ( appMPlayer.subWindow.State == wsWindowClosed ) exit_player( EXIT_QUIT );
+ if ( appMPlayer.subWindow.State == wsWindowClosed ) guiExit( EXIT_QUIT );
 
  if ( appMPlayer.subWindow.State == wsWindowFocusIn ) SubVisible++;
  if ( appMPlayer.subWindow.State == wsWindowFocusOut && metacity_hack != 3 ) SubVisible--;


More information about the MPlayer-cvslog mailing list