From b7747e5c0888c66271d9cdea707a6bc483fc44a2 Mon Sep 17 00:00:00 2001 From: Hominem te esse Date: Sun, 4 Mar 2012 17:47:44 +0100 Subject: [PATCH] fix for corrupted graphics when manipulating config files --- include/config.h | 1 + include/themes.h | 4 ++-- src/config.c | 2 ++ src/themes.c | 12 ++++++------ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/config.h b/include/config.h index 58f7efc..990c4a3 100644 --- a/include/config.h +++ b/include/config.h @@ -35,6 +35,7 @@ typedef struct { struct config_value_t *tail; char *filename; int modified; + u32 uid; } config_set_t; void configInit(char *prefix); diff --git a/include/themes.h b/include/themes.h index 106fd7b..a729225 100644 --- a/include/themes.h +++ b/include/themes.h @@ -27,7 +27,7 @@ typedef struct { typedef struct { // Attributes for: AttributeImage int currentUid; - int currentItemId; + u32 currentConfigId; char* currentValue; // Attributes for: AttributeImage & GameImage @@ -51,7 +51,7 @@ typedef struct { char* alias; int displayMode; - int currentItemId; + u32 currentConfigId; char* currentValue; } mutable_text_t; diff --git a/src/config.c b/src/config.c index 8a9a21a..20a91e0 100644 --- a/src/config.c +++ b/src/config.c @@ -13,6 +13,7 @@ #define CONFIG_INDEX_LAST 1 #define CONFIG_INDEX_APPS 2 +static u32 currentUID = 0; static config_set_t configFiles[CONFIG_FILE_NUM]; static char configPath[255] = "mc?:SYS-CONF/IPCONFIG.DAT"; @@ -169,6 +170,7 @@ config_set_t *configAlloc(int type, config_set_t *configSet, char *fileName) { if (!configSet) configSet = (config_set_t*) malloc(sizeof(config_set_t)); + configSet->uid = ++currentUID; configSet->type = type; configSet->head = NULL; configSet->tail = NULL; diff --git a/src/themes.c b/src/themes.c index d0291e9..938f9b4 100644 --- a/src/themes.c +++ b/src/themes.c @@ -85,7 +85,7 @@ static mutable_text_t* initMutableText(char* themePath, config_set_t* themeConfi char* value, char* alias, int displayMode, int sizingMode) { mutable_text_t* mutableText = (mutable_text_t*) malloc(sizeof(mutable_text_t)); - mutableText->currentItemId = -1; + mutableText->currentConfigId = 0; mutableText->currentValue = NULL; mutableText->alias = NULL; @@ -171,9 +171,9 @@ static void initStaticText(char* themePath, config_set_t* themeConfig, theme_t* static void drawAttributeText(struct menu_list* menu, struct submenu_list* item, config_set_t* config, struct theme_element* elem) { mutable_text_t* mutableText = (mutable_text_t*) elem->extended; if (config) { - if (mutableText->currentItemId != item->item.id) { + if (mutableText->currentConfigId != config->uid) { // force refresh - mutableText->currentItemId = item->item.id; + mutableText->currentConfigId = config->uid; mutableText->currentValue = NULL; if (configGetStr(config, mutableText->value, &mutableText->currentValue)) { if (mutableText->sizingMode == SIZING_WRAP) @@ -333,7 +333,7 @@ static mutable_image_t* initMutableImage(char* themePath, config_set_t* themeCon mutable_image_t* mutableImage = (mutable_image_t*) malloc(sizeof(mutable_image_t)); mutableImage->currentUid = -1; - mutableImage->currentItemId = -1; + mutableImage->currentConfigId = 0; mutableImage->currentValue = NULL; mutableImage->cache = NULL; mutableImage->cacheLinked = 0; @@ -467,10 +467,10 @@ static void initGameImage(char* themePath, config_set_t* themeConfig, theme_t* t static void drawAttributeImage(struct menu_list* menu, struct submenu_list* item, config_set_t* config, struct theme_element* elem) { mutable_image_t* attributeImage = (mutable_image_t*) elem->extended; if (config) { - if (attributeImage->currentItemId != item->item.id) { + if (attributeImage->currentConfigId != config->uid) { // force refresh attributeImage->currentUid = -1; - attributeImage->currentItemId = item->item.id; + attributeImage->currentConfigId = config->uid; attributeImage->currentValue = NULL; configGetStr(config, attributeImage->cache->suffix, &attributeImage->currentValue); } -- 2.11.4.GIT