[libadwaita/wip/exalm/new-glib: 7/13] animation: Don't leak widget and target
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/new-glib: 7/13] animation: Don't leak widget and target
- Date: Tue, 2 Nov 2021 20:41:20 +0000 (UTC)
commit 87a89ed88e95130f9cf9c275a1578b4fa0f50d34
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Nov 2 23:59:28 2021 +0500
animation: Don't leak widget and target
src/adw-animation.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/src/adw-animation.c b/src/adw-animation.c
index 521398bf..a8e649ca 100644
--- a/src/adw-animation.c
+++ b/src/adw-animation.c
@@ -169,12 +169,27 @@ adw_animation_constructed (GObject *object)
G_OBJECT_CLASS (adw_animation_parent_class)->constructed (object);
}
+static void
+adw_animation_dispose (GObject *object)
+{
+ AdwAnimation *self = ADW_ANIMATION (object);
+ AdwAnimationPrivate *priv = adw_animation_get_instance_private (self);
+
+ adw_animation_stop (self);
+
+ g_clear_object (&priv->target);
+ g_clear_object (&priv->widget);
+
+ G_OBJECT_CLASS (adw_animation_parent_class)->dispose (object);
+}
+
static void
adw_animation_class_init (AdwAnimationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = adw_animation_constructed;
+ object_class->dispose = adw_animation_dispose;
object_class->set_property = adw_animation_set_property;
object_class->get_property = adw_animation_get_property;
@@ -333,7 +348,8 @@ adw_animation_new (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (target_func != NULL, NULL);
- target = adw_animation_target_new(target_func, user_data);
+ target = adw_animation_target_new (target_func, user_data);
+
return g_object_new (ADW_TYPE_ANIMATION,
"widget", widget,
"value-from", from,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]