changeset 32893:c873777e957d

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.
author ib
date Sun, 27 Feb 2011 17:41:05 +0000
parents b5f21d533644
children f01aafc5a961
files gui/mplayer/gtk/sb.c gui/mplayer/play.c gui/skin/skin.c gui/skin/skin.h
diffstat 4 files changed, 20 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/gui/mplayer/gtk/sb.c	Sun Feb 27 15:25:20 2011 +0000
+++ b/gui/mplayer/gtk/sb.c	Sun Feb 27 17:41:05 2011 +0000
@@ -98,7 +98,7 @@
 	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;
--- a/gui/mplayer/play.c	Sun Feb 27 15:25:20 2011 +0000
+++ b/gui/mplayer/play.c	Sun Feb 27 17:41:05 2011 +0000
@@ -194,32 +194,20 @@
     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
--- a/gui/skin/skin.c	Sun Feb 27 15:25:20 2011 +0000
+++ b/gui/skin/skin.c	Sun Feb 27 17:41:05 2011 +0000
@@ -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 @@
     int (*func)(char *in);
 } _item;
 
-listItems *skinAppMPlayer = &appMPlayer;
 static listItems *defList;
 
 static int linenumber;
@@ -152,7 +152,7 @@
     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 @@
     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 @@
 
     mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] file: %s\n", fn);
 
-    appInitStruct(skinAppMPlayer);
+    appInitStruct(&appMPlayer);
+    fntFreeFont();
 
     linenumber = 0;
 
--- a/gui/skin/skin.h	Sun Feb 27 15:25:20 2011 +0000
+++ b/gui/skin/skin.h	Sun Feb 27 17:41:05 2011 +0000
@@ -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 *);