From 7d8a3a52ce445bb0c0fe6a4e30526e1bc864fc4f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 16 Oct 2015 19:52:50 +0200 Subject: [PATCH] GdkDevice: Do not free construct-only properties data on dispose() Those are not references to other objects, and the device will be mostly useless if those can't be set again anyway. https://bugzilla.gnome.org/show_bug.cgi?id=756625 --- gdk/gdkdevice.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c index 86bfbf4631..a1a59d27a0 100644 --- a/gdk/gdkdevice.c +++ b/gdk/gdkdevice.c @@ -63,6 +63,7 @@ enum { static guint signals [LAST_SIGNAL] = { 0 }; +static void gdk_device_finalize (GObject *object); static void gdk_device_dispose (GObject *object); static void gdk_device_set_property (GObject *object, guint prop_id, @@ -99,6 +100,7 @@ gdk_device_class_init (GdkDeviceClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->finalize = gdk_device_finalize; object_class->dispose = gdk_device_dispose; object_class->set_property = gdk_device_set_property; object_class->get_property = gdk_device_get_property; @@ -298,6 +300,25 @@ gdk_device_init (GdkDevice *device) device->axes = g_array_new (FALSE, TRUE, sizeof (GdkAxisInfo)); } +static void +gdk_device_finalize (GObject *object) +{ + GdkDevice *device = GDK_DEVICE (object); + + if (device->axes) + { + g_array_free (device->axes, TRUE); + device->axes = NULL; + } + + g_clear_pointer (&device->name, g_free); + g_clear_pointer (&device->keys, g_free); + g_clear_pointer (&device->vendor_id, g_free); + g_clear_pointer (&device->product_id, g_free); + + G_OBJECT_CLASS (gdk_device_parent_class)->finalize (object); +} + static void gdk_device_dispose (GObject *object) { @@ -315,21 +336,6 @@ gdk_device_dispose (GObject *object) device->associated = NULL; } - if (device->axes) - { - g_array_free (device->axes, TRUE); - device->axes = NULL; - } - - g_free (device->name); - g_free (device->keys); - - device->name = NULL; - device->keys = NULL; - - g_clear_pointer (&device->vendor_id, g_free); - g_clear_pointer (&device->product_id, g_free); - G_OBJECT_CLASS (gdk_device_parent_class)->dispose (object); }