[MPlayer-cvslog] r32980 - in trunk/gui: mplayer/gtk/sb.c mplayer/play.c skin/skin.c skin/skin.h

ib subversion at mplayerhq.hu
Sun Feb 27 18:41:05 CET 2011


Author: ib
Date: Sun Feb 27 18:41:05 2011
New Revision: 32980

Log:
Get rid of needless listItems variable and pointer.

The tmpList structure variable was only used to check whether a skin can be
read without error. After the check tmpList was erased and the same skin read
once again into another structure - the appropriate target structure. Now
error checking is done with skin reading into the target structure.

The separate skinAppMPlayer pointer was needless, because a skin will only be
read into the one global listItems structure appMPlayer, so that its address
can be used right away.

Freeing the listItems was done twice before and is now performed at a single
place, where the fonts are freed now as well - in skinRead() right before
skin reading starts.

As a result there is now only one listItems variable - the global appMPlayer;
memory is saved, passing around global variables and pointless double actions
are avoided.

Modified:
   trunk/gui/mplayer/gtk/sb.c
   trunk/gui/mplayer/play.c
   trunk/gui/skin/skin.c
   trunk/gui/skin/skin.h

Modified: trunk/gui/mplayer/gtk/sb.c
==============================================================================
--- trunk/gui/mplayer/gtk/sb.c	Sun Feb 27 16:25:20 2011	(r32979)
+++ trunk/gui/mplayer/gtk/sb.c	Sun Feb 27 18:41:05 2011	(r32980)
@@ -98,7 +98,7 @@ static void prButton( GtkObject * object
 	if ( strcmp( sbSelectedSkin,gtkOldSkin ) ) ChangeSkin( gtkOldSkin );
 	break;
    case 1: // ok
-	ChangeSkin( sbSelectedSkin );
+	ChangeSkin( sbSelectedSkin );   // NOTE TO MYSELF: skin already changed!
 	free( skinName );
 	skinName=strdup( sbSelectedSkin );
 	break;

Modified: trunk/gui/mplayer/play.c
==============================================================================
--- trunk/gui/mplayer/play.c	Sun Feb 27 16:25:20 2011	(r32979)
+++ trunk/gui/mplayer/play.c	Sun Feb 27 18:41:05 2011	(r32980)
@@ -194,32 +194,20 @@ void mplAbsSeek(float s)
     abs_seek_pos  = 3;
 }
 
-listItems tmpList;
-
 void ChangeSkin(char *name)
 {
-    int prev, bprev, ret;
+    int prev, bprev;
 
     prev  = appMPlayer.menuIsPresent;
     bprev = appMPlayer.barIsPresent;
 
     mainVisible = 0;
 
-    appInitStruct(&tmpList);
-    skinAppMPlayer = &tmpList;
-    fntFreeFont();
-    ret = skinRead(name);
-
-    appInitStruct(&tmpList);
-    skinAppMPlayer = &appMPlayer;
-    appInitStruct(&appMPlayer);
-
-    if (ret)
-        name = skinName;
-
-    if (skinRead(name)) {
+    if (skinRead(name) != 0) {
+        if (skinRead(skinName) != 0) {
         mainVisible = 1;
         return;
+        }
     }
 
     // reload menu window

Modified: trunk/gui/skin/skin.c
==============================================================================
--- trunk/gui/skin/skin.c	Sun Feb 27 16:25:20 2011	(r32979)
+++ trunk/gui/skin/skin.c	Sun Feb 27 18:41:05 2011	(r32980)
@@ -22,6 +22,7 @@
 #include "skin.h"
 #include "cut.h"
 #include "font.h"
+#include "gui/app.h"
 #include "gui/mplayer/widgets.h"
 
 #include "config.h"
@@ -34,7 +35,6 @@ typedef struct {
     int (*func)(char *in);
 } _item;
 
-listItems *skinAppMPlayer = &appMPlayer;
 static listItems *defList;
 
 static int linenumber;
@@ -152,7 +152,7 @@ static int cmd_section(char *in)
     defList = NULL;
 
     if (!strcmp(in, "movieplayer"))
-        defList = skinAppMPlayer;
+        defList = &appMPlayer;
 
     mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] sectionname: %s\n", in);
 
@@ -185,19 +185,19 @@ static int cmd_window(char *in)
     av_strlcpy(window_name, strlower(in), sizeof(window_name));
 
     if (!strncmp(in, "main", 4)) {
-        currSection  = &skinAppMPlayer->main;
-        currSubItem  = &skinAppMPlayer->NumberOfItems;
-        currSubItems = skinAppMPlayer->Items;
+        currSection  = &appMPlayer.main;
+        currSubItem  = &appMPlayer.NumberOfItems;
+        currSubItems = appMPlayer.Items;
     } else if (!strncmp(in, "sub", 3))
-        currSection = &skinAppMPlayer->sub;
+        currSection = &appMPlayer.sub;
     else if (!strncmp(in, "playbar", 7)) {
-        currSection  = &skinAppMPlayer->bar;
-        currSubItem  = &skinAppMPlayer->NumberOfBarItems;
-        currSubItems = skinAppMPlayer->barItems;
+        currSection  = &appMPlayer.bar;
+        currSubItem  = &appMPlayer.NumberOfBarItems;
+        currSubItems = appMPlayer.barItems;
     } else if (!strncmp(in, "menu", 4)) {
-        currSection  = &skinAppMPlayer->menuBase;
-        currSubItem  = &skinAppMPlayer->NumberOfMenuItems;
-        currSubItems = skinAppMPlayer->MenuItems;
+        currSection  = &appMPlayer.menuBase;
+        currSubItem  = &appMPlayer.NumberOfMenuItems;
+        currSubItems = appMPlayer.MenuItems;
     } else
         ERRORMESSAGE(MSGTR_UNKNOWNWINDOWTYPE);
 
@@ -885,7 +885,8 @@ int skinRead(char *dname)
 
     mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] file: %s\n", fn);
 
-    appInitStruct(skinAppMPlayer);
+    appInitStruct(&appMPlayer);
+    fntFreeFont();
 
     linenumber = 0;
 

Modified: trunk/gui/skin/skin.h
==============================================================================
--- trunk/gui/skin/skin.h	Sun Feb 27 16:25:20 2011	(r32979)
+++ trunk/gui/skin/skin.h	Sun Feb 27 18:41:05 2011	(r32980)
@@ -19,9 +19,7 @@
 #ifndef MPLAYER_GUI_SKIN_H
 #define MPLAYER_GUI_SKIN_H
 
-#include "gui/app.h"
-
-extern listItems *skinAppMPlayer;
+#include "gui/bitmap.h"
 
 int skinBPRead(char *, txSample *);
 int skinRead(char *);


More information about the MPlayer-cvslog mailing list