Mercurial > audlegacy
changeset 4581:cf6711eeb12f
implement event_queue_with_data_free()
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Wed, 21 May 2008 18:40:05 +0200 |
parents | 910ed095b5a9 |
children | 77f57ba8d7a4 |
files | src/audacious/eventqueue.c src/audacious/eventqueue.h src/audacious/input.c src/audacious/playlist.c src/audacious/ui_main_evlisteners.c |
diffstat | 5 files changed, 25 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/eventqueue.c Wed May 21 17:19:17 2008 +0200 +++ b/src/audacious/eventqueue.c Wed May 21 18:40:05 2008 +0200 @@ -27,6 +27,9 @@ hook_call(hq->name, hq->user_data); g_free(hq->name); + if (hq->free_data && hq->user_data) + g_free(hq->user_data); + g_slice_free(HookCallQueue, hq); return FALSE; @@ -42,6 +45,7 @@ hq = g_slice_new0(HookCallQueue); hq->name = g_strdup(name); hq->user_data = user_data; + hq->free_data = FALSE; g_idle_add_full(G_PRIORITY_HIGH_IDLE, eventqueue_handle, hq, NULL); } @@ -56,6 +60,22 @@ hq = g_slice_new0(HookCallQueue); hq->name = g_strdup(name); hq->user_data = user_data; + hq->free_data = FALSE; g_timeout_add(time, eventqueue_handle, hq); } + +void event_queue_with_data_free(const gchar *name, gpointer user_data) +{ + HookCallQueue *hq; + + g_return_if_fail(name != NULL); + g_return_if_fail(user_data != NULL); + + hq = g_slice_new0(HookCallQueue); + hq->name = g_strdup(name); + hq->user_data = user_data; + hq->free_data = TRUE; + + g_idle_add_full(G_PRIORITY_HIGH_IDLE, eventqueue_handle, hq, NULL); +} \ No newline at end of file
--- a/src/audacious/eventqueue.h Wed May 21 17:19:17 2008 +0200 +++ b/src/audacious/eventqueue.h Wed May 21 18:40:05 2008 +0200 @@ -28,9 +28,11 @@ typedef struct { gchar *name; gpointer *user_data; + gboolean free_data; } HookCallQueue; void event_queue(const gchar *name, gpointer user_data); void event_queue_timed(gint time, const gchar *name, gpointer user_data); +void event_queue_with_data_free(const gchar *name, gpointer user_data); #endif /* AUDACIOUS_EVENTQUEUE_H */
--- a/src/audacious/input.c Wed May 21 17:19:17 2008 +0200 +++ b/src/audacious/input.c Wed May 21 18:40:05 2008 +0200 @@ -781,5 +781,5 @@ input_set_info_text(gchar *text) { gchar *title = g_strdup(text); - event_queue("title change", title); + event_queue_with_data_free("title change", title); }
--- a/src/audacious/playlist.c Wed May 21 17:19:17 2008 +0200 +++ b/src/audacious/playlist.c Wed May 21 18:40:05 2008 +0200 @@ -1109,10 +1109,10 @@ msg->channels = nch; playback_set_sample_params(rate, freq, nch); - event_queue("playlist info change", msg); + event_queue_with_data_free("playlist info change", msg); text = playlist_get_info_text(playlist); - event_queue("title change", text); + event_queue_with_data_free("title change", text); if ( playlist->position ) hook_call( "playlist set info" , playlist->position );
--- a/src/audacious/ui_main_evlisteners.c Wed May 21 17:19:17 2008 +0200 +++ b/src/audacious/ui_main_evlisteners.c Wed May 21 18:40:05 2008 +0200 @@ -63,7 +63,6 @@ ui_skinned_textbox_set_text(mainwin_info, text); playlistwin_update_list(playlist_get_active()); - g_free(text); } static void @@ -187,8 +186,6 @@ PlaylistEventInfoChange *msg = (PlaylistEventInfoChange *) hook_data; mainwin_set_song_info(msg->bitrate, msg->samplerate, msg->channels); - - g_free(msg); } static void