[gtk+/a11y] Fix GtkSwitchAccessible type definition
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/a11y] Fix GtkSwitchAccessible type definition
- Date: Mon, 20 Jun 2011 04:03:05 +0000 (UTC)
commit 95f00beda31f780701b8bb7c9cb02f847e32b9cf
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 20 00:00:39 2011 -0400
Fix GtkSwitchAccessible type definition
It turns out that ATK_DEFINE_TYPE_WITH_CODE() is broken; it
tells GType that the class and instance size for the accessible
type are the same as for its parent type. Which is not true
if your instance struct has members such as 'description' here.
This was causing hard-to-track-down memory corruption, since
description and the GtkAccessible private pointer were sharing
the same memory location.
gtk/gtkswitch.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index 9b831c7..fc92ea0 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -1015,10 +1015,19 @@ struct _GtkSwitchAccessible
guint action_idle;
};
+/* FIXME: We really want to use GailWidgetClass here */
+struct _GtkSwitchAccessibleClass
+{
+ GtkAccessibleClass parent_class;
+
+ gpointer f1;
+ gpointer f2;
+};
+
static void atk_action_interface_init (AtkActionIface *iface);
-ATK_DEFINE_TYPE_WITH_CODE (GtkSwitchAccessible, _gtk_switch_accessible, GTK_TYPE_SWITCH,
- G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
+G_DEFINE_TYPE_WITH_CODE (GtkSwitchAccessible, _gtk_switch_accessible, g_type_from_name ("GailWidget"),
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
static AtkStateSet *
gtk_switch_accessible_ref_state_set (AtkObject *accessible)
@@ -1079,6 +1088,7 @@ _gtk_switch_accessible_init (GtkSwitchAccessible *self)
{
self->description = NULL;
self->action_idle = 0;
+g_print ("switch action description inited to: %s\n", self->description);
}
/* accessibility: action interface */
@@ -1100,8 +1110,9 @@ static const gchar *
gtk_switch_action_get_description (AtkAction *action,
gint i)
{
- GtkSwitchAccessible *accessible = (GtkSwitchAccessible*)action;
+ GtkSwitchAccessible *accessible = (GtkSwitchAccessible *)action;
+g_print ("switch action description: %s\n", accessible->description);
return accessible->description;
}
@@ -1112,6 +1123,7 @@ gtk_switch_action_set_description (AtkAction *action,
{
GtkSwitchAccessible *accessible = (GtkSwitchAccessible*)action;
+g_print ("switch action set description: %s\n", description);
g_free (accessible->description);
accessible->description = g_strdup (description);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]