ui/common/types.c

changeset 612
8570430391b3
parent 611
a5b393e766c4
child 622
9090faa4094b
--- a/ui/common/types.c	Mon Jun 09 08:41:16 2025 +0200
+++ b/ui/common/types.c	Mon Jun 09 08:47:57 2025 +0200
@@ -396,17 +396,29 @@
     }
 }
 
-void ui_image_set(UiGeneric *g, void *img) {
-    // TODO: ref?
+char* ui_text_get(UiText* s) {
+    if (s) {
+        return s->get ? s->get(s) : s->value.ptr;
+    }
+    else {
+        return 0;
+    }
+}
+
+void ui_generic_set_image(UiGeneric *g, void *img) {
     if(g->set) {
         g->set(g, img, UI_IMAGE_OBJECT_TYPE);
     } else {
+        if(g->value) {
+            ui_image_unref(g->value);
+        }
+        ui_image_ref(img);
         g->value = img;
         g->type = UI_IMAGE_OBJECT_TYPE;
     }
 }
 
-void* ui_image_get(UiGeneric *g) {
+void* ui_generic_get_image(UiGeneric *g) {
     if(g->type) {
         if(!strcmp(g->type, UI_IMAGE_OBJECT_TYPE)) {
             return g->value;
@@ -418,16 +430,6 @@
 }
 
 
-char* ui_text_get(UiText* s) {
-    if (s) {
-        return s->get ? s->get(s) : s->value.ptr;
-    }
-    else {
-        return 0;
-    }
-}
-
-
 // private functions
 void uic_int_copy(UiInteger *from, UiInteger *to) {
     to->get = from->get;

mercurial