Fix nasty bug whith skin management.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1210 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues 2009-11-16 23:09:06 +00:00
parent c39f643808
commit 63191fec2f
3 changed files with 14 additions and 8 deletions

7
init.c
View File

@ -2582,8 +2582,11 @@ void Set_current_skin(const char *skinfile, T_Gui_skin *gfx)
Gfx = gfx;
// Change config
free(Config.Skin_file);
Config.Skin_file = strdup(skinfile);
if(Config.Skin_file != skinfile) // Happens when loading the initial skin
{
free(Config.Skin_file);
Config.Skin_file = strdup(skinfile);
}
Config.Fav_menu_colors[0] = gfx->Default_palette[gfx->Color_black];
Config.Fav_menu_colors[1] = gfx->Default_palette[gfx->Color_dark];

3
main.c
View File

@ -306,12 +306,10 @@ void Analyze_command_line(int argc, char * argv[])
// Separate path from filename
Extract_path(Main_file_directory, buffer);
Extract_filename(Main_filename, buffer);
DEBUG(Main_filename, 0);
free(buffer);
} else {
Extract_path(Spare_file_directory, buffer);
Extract_filename(Spare_filename, buffer);
DEBUG(Spare_filename, 1);
free(buffer);
}
}
@ -835,6 +833,7 @@ int main(int argc,char * argv[])
break;
}
}
Main_handler();
Program_shutdown();

View File

@ -24,7 +24,9 @@
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "const.h"
#include "errors.h"
#include "global.h"
#include "misc.h"
#include "readini.h"
@ -175,7 +177,7 @@ int Load_INI_get_string(FILE * file,char * buffer,char * option_name,char * retu
do
{
// On lit une ligne dans le fichier:
if (fgets(buffer,1024,file)==0)
if (fgets(buffer,1024,file)==NULL)
{
free(upper_buffer);
free(option_upper);
@ -435,13 +437,13 @@ int Load_INI(T_Config * conf)
strcpy(filename,Config_directory);
strcat(filename,"gfx2.ini");
file=fopen(filename,"rb");
file=fopen(filename,"r");
if (file==0)
{
// Si le fichier ini est absent on le relit depuis gfx2def.ini
strcpy(filename,Data_directory);
strcat(filename,"gfx2def.ini");
file=fopen(filename,"rb");
file=fopen(filename,"r");
if (file == 0)
{
free(filename);
@ -818,7 +820,9 @@ int Load_INI(T_Config * conf)
// Optional, name of skin file. (>2.0)
if(!Load_INI_get_string(file,buffer,"Skin_file",value_label,1))
{
conf->Skin_file = strdup(value_label);
}
else
conf->Skin_file = strdup("skin_modern.png");