From 17af08b04da9645f89fe47436ba6c9e1d3a9e32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 24 Aug 2019 13:45:16 +0200 Subject: [PATCH] GdsOutputrenderer: progress-changed signal: Status message is now freed inside the GdsOutputRenderer. This is safe because the signals are handled back to back inside the emit function. Therefore, it can be freed directly after emission. This solves the problem of the status message not being freed if no handler is connected to the signal. --- gds-render-gui.c | 3 +-- output-renderers/gds-output-renderer.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/gds-render-gui.c b/gds-render-gui.c index abcfa07..6520ae1 100644 --- a/gds-render-gui.c +++ b/gds-render-gui.c @@ -293,7 +293,7 @@ static void async_rendering_finished_callback(GdsOutputRenderer *renderer, gpoin g_object_unref(renderer); } -static void async_rendering_status_update_callback(GdsOutputRenderer *renderer, char *status_message, gpointer data) +static void async_rendering_status_update_callback(GdsOutputRenderer *renderer, const char *status_message, gpointer data) { GdsRenderGui *gui; (void)renderer; @@ -301,7 +301,6 @@ static void async_rendering_status_update_callback(GdsOutputRenderer *renderer, gui = RENDERER_GUI(data); activity_bar_set_busy(gui->activity_status_bar, status_message); - g_free(status_message); } /** diff --git a/output-renderers/gds-output-renderer.c b/output-renderers/gds-output-renderer.c index d948f35..e8f7fc1 100644 --- a/output-renderers/gds-output-renderer.c +++ b/output-renderers/gds-output-renderer.c @@ -405,7 +405,7 @@ static gboolean idle_event_processor_callback(gpointer user_data) priv = gds_output_renderer_get_instance_private(renderer); if (g_mutex_trylock(&priv->idle_function_parameters.message_lock)) { - status_message = g_strdup(priv->idle_function_parameters.status_message); + status_message = priv->idle_function_parameters.status_message; g_signal_emit(renderer, gds_output_renderer_signals[ASYNC_PROGRESS_CHANGED], 0, status_message); g_free(priv->idle_function_parameters.status_message); priv->idle_function_parameters.status_message = NULL;