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
This commit is contained in:
Matthias Clasen 2008-09-27 00:47:45 +00:00
parent 474033176e
commit abe8d89fd9
4 changed files with 44 additions and 14 deletions

View File

@ -1,3 +1,15 @@
2008-09-26 Matthias Clasen <mclasen@redhat.com>
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
2008-09-26 Matthias Clasen <mclasen@redhat.com>
Bug 553578 - tabs are not drawn correctly

View File

@ -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);

View File

@ -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;

View File

@ -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);
}
}