forked from len0rd/rockbox
skin_engine: make sure to free all buflib allocations so we dont leak handles/memory
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30554 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0cfd7a3888
commit
81343bae5d
2 changed files with 53 additions and 34 deletions
|
|
@ -55,34 +55,7 @@ void theme_init_buffer(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void settings_apply_skins(void)
|
void skin_data_free_buflib_allocs(struct wps_data *wps_data);
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
skin_buffer_init(skin_buffer, SKIN_BUFFER_SIZE);
|
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
skin_backdrop_init();
|
|
||||||
skin_font_init();
|
|
||||||
#endif
|
|
||||||
gui_sync_skin_init();
|
|
||||||
|
|
||||||
/* Make sure each skin is loaded */
|
|
||||||
for (i=0; i<SKINNABLE_SCREENS_COUNT; i++)
|
|
||||||
{
|
|
||||||
FOR_NB_SCREENS(j)
|
|
||||||
skin_get_gwps(i, j);
|
|
||||||
}
|
|
||||||
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
|
||||||
skin_backdrops_preload(); /* should maybe check the retval here... */
|
|
||||||
#endif
|
|
||||||
viewportmanager_theme_changed(THEME_STATUSBAR);
|
|
||||||
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
|
||||||
FOR_NB_SCREENS(i)
|
|
||||||
skin_backdrop_show(sb_get_backdrop(i));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char* wps_default_skin(enum screen_type screen);
|
char* wps_default_skin(enum screen_type screen);
|
||||||
char* default_radio_skin(enum screen_type screen);
|
char* default_radio_skin(enum screen_type screen);
|
||||||
|
|
||||||
|
|
@ -130,6 +103,40 @@ void gui_sync_skin_init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void settings_apply_skins(void)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (i=0; i<SKINNABLE_SCREENS_COUNT; i++)
|
||||||
|
{
|
||||||
|
FOR_NB_SCREENS(j)
|
||||||
|
skin_data_free_buflib_allocs(&skins[j][i].data);
|
||||||
|
}
|
||||||
|
|
||||||
|
skin_buffer_init(skin_buffer, SKIN_BUFFER_SIZE);
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
skin_backdrop_init();
|
||||||
|
skin_font_init();
|
||||||
|
#endif
|
||||||
|
gui_sync_skin_init();
|
||||||
|
|
||||||
|
/* Make sure each skin is loaded */
|
||||||
|
for (i=0; i<SKINNABLE_SCREENS_COUNT; i++)
|
||||||
|
{
|
||||||
|
FOR_NB_SCREENS(j)
|
||||||
|
skin_get_gwps(i, j);
|
||||||
|
}
|
||||||
|
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
||||||
|
skin_backdrops_preload(); /* should maybe check the retval here... */
|
||||||
|
#endif
|
||||||
|
viewportmanager_theme_changed(THEME_STATUSBAR);
|
||||||
|
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
||||||
|
FOR_NB_SCREENS(i)
|
||||||
|
skin_backdrop_show(sb_get_backdrop(i));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void skin_load(enum skinnable_screens skin, enum screen_type screen,
|
void skin_load(enum skinnable_screens skin, enum screen_type screen,
|
||||||
const char *buf, bool isfile)
|
const char *buf, bool isfile)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1424,12 +1424,12 @@ static bool check_feature_tag(const int type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* This is used to free any buflib allocations before the rest of
|
||||||
* initial setup of wps_data; does reset everything
|
* wps_data is reset.
|
||||||
* except fields which need to survive, i.e.
|
* The call to this in settings_apply_skins() is the last chance to do
|
||||||
*
|
* any core_free()'s before wps_data is trashed and those handles lost
|
||||||
**/
|
*/
|
||||||
static void skin_data_reset(struct wps_data *wps_data)
|
void skin_data_free_buflib_allocs(struct wps_data *wps_data)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
#ifndef __PCTOOL__
|
#ifndef __PCTOOL__
|
||||||
|
|
@ -1442,6 +1442,18 @@ static void skin_data_reset(struct wps_data *wps_data)
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* initial setup of wps_data; does reset everything
|
||||||
|
* except fields which need to survive, i.e.
|
||||||
|
* Also called if the load fails
|
||||||
|
**/
|
||||||
|
static void skin_data_reset(struct wps_data *wps_data)
|
||||||
|
{
|
||||||
|
skin_data_free_buflib_allocs(wps_data);
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
wps_data->images = NULL;
|
wps_data->images = NULL;
|
||||||
#endif
|
#endif
|
||||||
wps_data->tree = NULL;
|
wps_data->tree = NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue