Compare commits

..

3 Commits

Author SHA1 Message Date
94ac44ddc5 Set task name of rendering GTask 2019-08-23 21:50:16 +02:00
1cbacef56c Fix reference counting issue of the LayerSettings inside the
GdsOutputRenderer class.

The LayerSettings element is now disposed of properly.
2019-08-23 21:40:21 +02:00
cae6a9c6c3 LayerSettings: Fix memory leak: GList of layer infos was not freed. Add
dispose to LayerSettings which takes care of this task.
2019-08-23 21:38:59 +02:00
2 changed files with 32 additions and 12 deletions

View File

@ -39,9 +39,36 @@ static void layer_settings_init(LayerSettings *self)
self->layer_infos = NULL; self->layer_infos = NULL;
} }
static void layer_info_delete_with_name(struct layer_info *const info)
{
if (!info)
return;
if (info->name)
free(info->name);
free(info);
}
static void layer_settings_dispose(GObject *obj)
{
LayerSettings *self;
self = GDS_RENDER_LAYER_SETTINGS(obj);
if (self->layer_infos) {
g_list_free_full(self->layer_infos, (GDestroyNotify)layer_info_delete_with_name);
self->layer_infos = NULL;
}
G_OBJECT_CLASS(layer_settings_parent_class)->dispose(obj);
}
static void layer_settings_class_init(LayerSettingsClass *klass) static void layer_settings_class_init(LayerSettingsClass *klass)
{ {
(void)klass; GObjectClass *oclass;
oclass = G_OBJECT_CLASS(klass);
oclass->dispose = layer_settings_dispose;
return; return;
} }
@ -76,16 +103,6 @@ static struct layer_info *layer_info_copy(const struct layer_info * const info)
return copy; return copy;
} }
static void layer_info_delete_with_name(struct layer_info *const info)
{
if (!info)
return;
if (info->name)
free(info->name);
free(info);
}
LayerSettings *layer_settings_new() LayerSettings *layer_settings_new()
{ {
return g_object_new(GDS_RENDER_TYPE_LAYER_SETTINGS, NULL); return g_object_new(GDS_RENDER_TYPE_LAYER_SETTINGS, NULL);

View File

@ -262,9 +262,10 @@ LayerSettings *gds_output_renderer_get_and_ref_layer_settings(GdsOutputRenderer
/* Acquire settings lock */ /* Acquire settings lock */
g_mutex_lock(&priv->settings_lock); g_mutex_lock(&priv->settings_lock);
/* This function seems to already reference the LayerSettings object */
g_object_get(renderer, "layer-settings", &ret, NULL); g_object_get(renderer, "layer-settings", &ret, NULL);
/* Reference it, so it is not cleared by another thread overwriting the property */ /* Reference it, so it is not cleared by another thread overwriting the property */
g_object_ref(ret); //g_object_ref(ret);
/* It is now safe to clear the lock */ /* It is now safe to clear the lock */
g_mutex_unlock(&priv->settings_lock); g_mutex_unlock(&priv->settings_lock);
@ -371,6 +372,8 @@ int gds_output_renderer_render_output_async(GdsOutputRenderer *renderer, struct
} }
priv->task = g_task_new(renderer, NULL, gds_output_renderer_async_finished, NULL); priv->task = g_task_new(renderer, NULL, gds_output_renderer_async_finished, NULL);
g_task_set_name(priv->task, "Rendering Thread");
g_mutex_lock(&priv->settings_lock); g_mutex_lock(&priv->settings_lock);
priv->async_params.cell = cell; priv->async_params.cell = cell;
priv->async_params.scale = scale; priv->async_params.scale = scale;