summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorMatthias Clasen <matthiasc@src.gnome.org>2008-09-27 00:47:45 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2008-09-27 00:47:45 +0000
commitabe8d89fd9e7275c46e5556af2824a6fd2dbc787 (patch)
tree02077776de62d6f8461660ca2d8077471ccc85f5 /gdk
parent474033176effa187b02f0bcebb0d367d2bd13285 (diff)
downloadgtk+-abe8d89fd9e7275c46e5556af2824a6fd2dbc787.tar.gz
Bug 553803 – eventually call XCloseDevice on XOpenDevice results
* gdk/x11/gdkinput.c: Add a finalize function for device objects, and call XCloseDevice there. * gdk/x11/gdkinput-x11.c: * gdk/x11/gdkdisplay-x11.c: Move freeing of device objects to the finalize function. Patch by Caolan McNamara svn path=/trunk/; revision=21529
Diffstat (limited to 'gdk')
-rw-r--r--gdk/x11/gdkdisplay-x11.c1
-rw-r--r--gdk/x11/gdkinput-x11.c4
-rw-r--r--gdk/x11/gdkinput.c41
3 files changed, 32 insertions, 14 deletions
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 08b77da0e4..d791975155 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -830,7 +830,6 @@ gdk_display_x11_finalize (GObject *object)
g_slist_free (display_x11->event_types);
/* input GdkDevice list */
- /* FIXME need to write finalize fct */
g_list_foreach (display_x11->input_devices, (GFunc) g_object_unref, NULL);
g_list_free (display_x11->input_devices);
diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c
index deeb8422b0..8faf704845 100644
--- a/gdk/x11/gdkinput-x11.c
+++ b/gdk/x11/gdkinput-x11.c
@@ -246,10 +246,6 @@ gdk_input_device_new (GdkDisplay *display,
error:
- g_free (gdkdev->info.name);
- g_free (gdkdev->axes);
- g_free (gdkdev->info.keys);
- g_free (gdkdev->info.axes);
g_object_unref (gdkdev);
return NULL;
diff --git a/gdk/x11/gdkinput.c b/gdk/x11/gdkinput.c
index 98840bb0a4..4f2159f5f6 100644
--- a/gdk/x11/gdkinput.c
+++ b/gdk/x11/gdkinput.c
@@ -63,6 +63,9 @@ _gdk_init_input_core (GdkDisplay *display)
private->display = display;
}
+static void gdk_device_class_init (GdkDeviceClass *klass);
+static void gdk_device_finalize (GObject *object);
+
GType
gdk_device_get_type (void)
{
@@ -75,7 +78,7 @@ gdk_device_get_type (void)
sizeof (GdkDeviceClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
- (GClassInitFunc) NULL,
+ (GClassInitFunc) gdk_device_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkDevicePrivate),
@@ -91,6 +94,33 @@ gdk_device_get_type (void)
return object_type;
}
+static void
+gdk_device_class_init (GdkDeviceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gdk_device_finalize;
+}
+
+static void
+gdk_device_finalize (GObject *object)
+{
+ GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)GDK_DEVICE(object);
+
+ if (!GDK_IS_CORE (gdkdev))
+ {
+#ifndef XINPUT_NONE
+ if (gdkdev->xdevice)
+ XCloseDevice (GDK_DISPLAY_XDISPLAY(gdkdev->display), gdkdev->xdevice);
+ g_free (gdkdev->axes);
+#endif /* !XINPUT_NONE */
+
+ g_free (gdkdev->info.name);
+ g_free (gdkdev->info.keys);
+ g_free (gdkdev->info.axes);
+ }
+}
+
/**
* gdk_devices_list:
*
@@ -403,14 +433,7 @@ _gdk_input_exit (void)
if (!GDK_IS_CORE (gdkdev))
{
gdk_device_set_mode (&gdkdev->info, GDK_MODE_DISABLED);
-
- g_free(gdkdev->info.name);
-#ifndef XINPUT_NONE
- g_free(gdkdev->axes);
-#endif
- g_free(gdkdev->info.axes);
- g_free(gdkdev->info.keys);
- g_free(gdkdev);
+ g_object_unref(gdkdev);
}
}