This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch main
in repository eradio.
View the commit online.
commit d85a181eee3c3bcaae99a85b177b862ccf5558df
Author: politebot <[email protected]>
AuthorDate: Sat Oct 11 06:12:32 2025 -0500
Fix memory leak, cache favicons
---
src/http.c | 30 +++++++++++++++++++++++++++++-
src/station_list.c | 16 ++++++++++++++--
src/ui.c | 52 ++++++++++++++++++++++++++--------------------------
3 files changed, 69 insertions(+), 29 deletions(-)
diff --git a/src/http.c b/src/http.c
index ccd7b3f..c8b03a5 100644
--- a/src/http.c
+++ b/src/http.c
@@ -6,6 +6,7 @@
#include <arpa/inet.h>
#include <time.h>
#include <string.h>
+#include <Ecore_File.h>
#include "http.h"
#include "station_list.h"
@@ -192,10 +193,29 @@ _handle_icon_complete(Ecore_Con_Event_Url_Complete *ev)
if (icon_ctx && icon_ctx->image_data)
{
Elm_Object_Item *it = icon_ctx->list_item;
+ Station *st = elm_object_item_data_get(it);
Evas_Object *icon = elm_object_item_part_content_get(it, "start");
const char *ext = strrchr(ecore_con_url_url_get(ev->url_con), '.');
if (ext) ext++;
+ if (st && st->stationuuid)
+ {
+ char cache_dir[PATH_MAX];
+ const char *home = getenv("HOME");
+ snprintf(cache_dir, sizeof(cache_dir), "%s/.cache/eradio/favicons", home);
+ ecore_file_mkpath(cache_dir);
+
+ char cache_path[PATH_MAX];
+ snprintf(cache_path, sizeof(cache_path), "%s/%s", cache_dir, st->stationuuid);
+
+ FILE *f = fopen(cache_path, "wb");
+ if (f)
+ {
+ fwrite(eina_binbuf_string_get(icon_ctx->image_data), 1, eina_binbuf_length_get(icon_ctx->image_data), f);
+ fclose(f);
+ }
+ }
+
elm_image_memfile_set(icon, eina_binbuf_string_get(icon_ctx->image_data), eina_binbuf_length_get(icon_ctx->image_data), (char *)ext, NULL);
}
@@ -265,7 +285,15 @@ _handle_station_list_complete(Ecore_Con_Event_Url_Complete *ev)
if (d_ctx->new_search)
{
- eina_list_free(ad->stations);
+ Station *st;
+ EINA_LIST_FREE(ad->stations, st)
+ {
+ eina_stringshare_del(st->name);
+ eina_stringshare_del(st->url);
+ eina_stringshare_del(st->favicon);
+ eina_stringshare_del(st->stationuuid);
+ free(st);
+ }
ad->stations = NULL;
}
diff --git a/src/station_list.c b/src/station_list.c
index 4319b56..eca03a0 100644
--- a/src/station_list.c
+++ b/src/station_list.c
@@ -1,3 +1,4 @@
+#include <Ecore_File.h>
#include "station_list.h"
#include "radio_player.h"
#include "http.h"
@@ -83,9 +84,20 @@ station_list_populate(AppData *ad, Eina_List *stations, Eina_Bool new_search)
evas_object_smart_callback_add(fav_btn, "clicked", _favorite_remove_btn_clicked_cb, ctx);
}
- if (st->favicon && st->favicon[0])
+ if (st->favicon && st->favicon[0] && st->stationuuid)
{
- http_download_icon(ad, li, st->favicon);
+ char cache_path[PATH_MAX];
+ const char *home = getenv("HOME");
+ snprintf(cache_path, sizeof(cache_path), "%s/.cache/eradio/favicons/%s", home, st->stationuuid);
+
+ if (ecore_file_exists(cache_path))
+ {
+ elm_image_file_set(icon, cache_path, NULL);
+ }
+ else
+ {
+ http_download_icon(ad, li, st->favicon);
+ }
}
}
elm_list_go(ad->list);
diff --git a/src/ui.c b/src/ui.c
index 1162006..92f10c0 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -155,11 +155,11 @@ ui_create(AppData *ad)
evas_object_show(ad->reverse_check);
// Server selection hoversel, populated after HTTP init discovers servers
- ad->server_hoversel = elm_hoversel_add(ad->win);
- elm_hoversel_hover_parent_set(ad->server_hoversel, ad->win);
- elm_object_text_set(ad->server_hoversel, "server");
- elm_box_pack_end(ad->search_bar, ad->server_hoversel);
- evas_object_show(ad->server_hoversel);
+ /* ad->server_hoversel = elm_hoversel_add(ad->win); */
+ /* elm_hoversel_hover_parent_set(ad->server_hoversel, ad->win); */
+ /* elm_object_text_set(ad->server_hoversel, "server"); */
+ /* elm_box_pack_end(ad->search_bar, ad->server_hoversel); */
+ /* evas_object_show(ad->server_hoversel); */
ad->search_btn = elm_button_add(ad->win);
elm_object_text_set(ad->search_btn, "Search");
@@ -232,29 +232,29 @@ ui_create(AppData *ad)
void ui_update_server_list(AppData *ad)
{
- if (!ad || !ad->server_hoversel) return;
- Eina_List *l; const char *host;
- EINA_LIST_FOREACH(ad->api_servers, l, host)
- {
- elm_hoversel_item_add(ad->server_hoversel, host, NULL, ELM_ICON_NONE, _server_item_selected_cb, ad);
- }
- if (ad->api_selected && ad->api_selected[0])
- elm_object_text_set(ad->server_hoversel, ad->api_selected);
+ /* if (!ad || !ad->server_hoversel) return; */
+ /* Eina_List *l; const char *host; */
+ /* EINA_LIST_FOREACH(ad->api_servers, l, host) */
+ /* { */
+ /* elm_hoversel_item_add(ad->server_hoversel, host, NULL, ELM_ICON_NONE, _server_item_selected_cb, ad); */
+ /* } */
+ /* if (ad->api_selected && ad->api_selected[0]) */
+ /* elm_object_text_set(ad->server_hoversel, ad->api_selected); */
}
-static void _server_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
-{
- AppData *ad = data;
- if (!ad) return;
- Elm_Object_Item *it = event_info;
- const char *label = elm_object_item_text_get(it);
- if (label && label[0])
- {
- elm_object_text_set(obj, label);
- if (ad->api_selected) eina_stringshare_del(ad->api_selected);
- ad->api_selected = eina_stringshare_add(label);
- }
-}
+/* static void _server_item_selected_cb(void *data, Evas_Object *obj, void *event_info) */
+/* { */
+/* AppData *ad = data; */
+/* if (!ad) return; */
+/* Elm_Object_Item *it = event_info; */
+/* const char *label = elm_object_item_text_get(it); */
+/* if (label && label[0]) */
+/* { */
+/* elm_object_text_set(obj, label); */
+/* if (ad->api_selected) eina_stringshare_del(ad->api_selected); */
+/* ad->api_selected = eina_stringshare_add(label); */
+/* } */
+/* } */
static void
_tb_favorites_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.