ui/common/properties.c

changeset 110
c00e968d018b
parent 108
77254bd6dccb
--- a/ui/common/properties.c	Sun Aug 24 15:24:16 2025 +0200
+++ b/ui/common/properties.c	Sat Oct 04 14:52:59 2025 +0200
@@ -73,7 +73,7 @@
 #define UI_ENV_HOME "USERPROFILE"
 #endif
 
-char* ui_configfile(char *name) {
+char* ui_configfile(const char *name) {
     const char *appname = ui_appname();
     if(!appname) {
         return NULL;
@@ -128,6 +128,7 @@
 
 void uic_load_app_properties() {
     application_properties = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 128);
+    application_properties->collection.simple_destructor = free;
     
     if(!ui_appname()) {
         // applications without name cannot load app properties
@@ -202,7 +203,11 @@
 }
 
 void ui_set_property(const char *name, const char *value) {
-    cxMapPut(application_properties, name, (char*)value);
+    if(value) {
+        cxMapPut(application_properties, name, strdup(value));
+    } else {
+        cxMapRemove(application_properties, name);
+    }
 }
 
 const char* ui_set_default_property(const char *name, const char *value) {
@@ -241,12 +246,14 @@
 
 #ifndef UI_COCOA
 
-void ui_locales_dir(char *path) {
-    locales_dir = path;
+void ui_locales_dir(const char *path) {
+    free(locales_dir);
+    locales_dir = path ? strdup(path) : NULL;
 }
 
-void ui_pixmaps_dir(char *path) {
-    pixmaps_dir = path;
+void ui_pixmaps_dir(const char *path) {
+    free(pixmaps_dir);
+    pixmaps_dir = path ? strdup(path) : NULL;
 }
 
 char* uic_get_image_path(const char *imgfilename) {
@@ -257,7 +264,7 @@
     }
 }
 
-void ui_load_lang(char *locale) {
+void ui_load_lang(const char *locale) {
     if(!locale) {
         locale = "en_EN";
     }
@@ -319,12 +326,12 @@
     return 0;
 }
 
-char* uistr(char *name) {
+char* uistr(const char *name) {
     char *value = uistr_n(name);
     return value ? value : "missing string";
 }
 
-char* uistr_n(char *name) {
+char* uistr_n(const char *name) {
     if(!language) {
         return NULL;
     }

mercurial