LayerSettings: Fix memory leak: GList of layer infos was not freed. Add
dispose to LayerSettings which takes care of this task.
This commit is contained in:
parent
d5dde3658d
commit
cae6a9c6c3
@ -39,9 +39,36 @@ static void layer_settings_init(LayerSettings *self)
|
||||
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)
|
||||
{
|
||||
(void)klass;
|
||||
GObjectClass *oclass;
|
||||
|
||||
oclass = G_OBJECT_CLASS(klass);
|
||||
oclass->dispose = layer_settings_dispose;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -76,16 +103,6 @@ static struct layer_info *layer_info_copy(const struct layer_info * const info)
|
||||
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()
|
||||
{
|
||||
return g_object_new(GDS_RENDER_TYPE_LAYER_SETTINGS, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user