Gui skins: Added memory checks and correctness
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@877 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
1c53b5dd7f
commit
1910a39fd4
21
buttons.c
21
buttons.c
@ -1278,13 +1278,28 @@ void Button_Skins(void)
|
|||||||
while ( (clicked_button!=1) && (Key!=SDLK_RETURN) && (clicked_button !=5) && (Key != SDLK_ESCAPE));
|
while ( (clicked_button!=1) && (Key!=SDLK_RETURN) && (clicked_button !=5) && (Key != SDLK_ESCAPE));
|
||||||
|
|
||||||
if(clicked_button == 1 || Key == SDLK_RETURN)
|
if(clicked_button == 1 || Key == SDLK_RETURN)
|
||||||
|
{
|
||||||
|
T_Gui_skin * gfx = (T_Gui_skin *)malloc(sizeof(T_Gui_skin));
|
||||||
|
if (gfx == NULL)
|
||||||
|
{
|
||||||
|
Error(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
strcpy(skinsdir,"skins/");
|
strcpy(skinsdir,"skins/");
|
||||||
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,skinsdir+6,NULL);
|
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,skinsdir+6,NULL);
|
||||||
Load_graphics(Gfx, skinsdir);
|
Load_graphics(gfx, skinsdir);
|
||||||
|
if (0) // Error
|
||||||
|
{
|
||||||
|
free(gfx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(Gfx);
|
||||||
|
Gfx = gfx;
|
||||||
strcpy(Config_choisie.SkinFile,skinsdir+6);
|
strcpy(Config_choisie.SkinFile,skinsdir+6);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Font selection
|
// Font selection
|
||||||
if (Config_choisie.Font)
|
if (Config_choisie.Font)
|
||||||
Menu_font=Gfx->Fun_font;
|
Menu_font=Gfx->Fun_font;
|
||||||
|
|||||||
7
main.c
7
main.c
@ -687,6 +687,13 @@ void Program_shutdown(void)
|
|||||||
free(Spare_screen);
|
free(Spare_screen);
|
||||||
free(Main_screen);
|
free(Main_screen);
|
||||||
|
|
||||||
|
// Free the skin (Gui graphics) data
|
||||||
|
if (Gfx)
|
||||||
|
{
|
||||||
|
free(Gfx);
|
||||||
|
Gfx=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// On prend bien soin de passer dans le répertoire initial:
|
// On prend bien soin de passer dans le répertoire initial:
|
||||||
if (chdir(Initial_directory)!=-1)
|
if (chdir(Initial_directory)!=-1)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user