[gtk+/wip/carlosg/event-as-object: 826/844] gtk/a11y: Use allocated events



commit f1096a1146a45fbbf27ac9a82dc0452670f058b0
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 25 12:26:32 2017 +0200

    gtk/a11y: Use allocated events
    
    Using stack allocated GdkEvent will not be ok when they become
    objects.

 gtk/a11y/gtkentryaccessible.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/gtk/a11y/gtkentryaccessible.c b/gtk/a11y/gtkentryaccessible.c
index 282f305..1061774 100644
--- a/gtk/a11y/gtkentryaccessible.c
+++ b/gtk/a11y/gtkentryaccessible.c
@@ -221,7 +221,7 @@ gtk_entry_icon_accessible_do_action (AtkAction *action,
   GtkEntryIconAccessible *icon = (GtkEntryIconAccessible *)action;
   GtkWidget *widget;
   GtkEntry *gtk_entry;
-  GdkEvent event;
+  GdkEvent *event;
   GdkRectangle icon_area;
 
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (icon->entry));
@@ -241,16 +241,17 @@ gtk_entry_icon_accessible_do_action (AtkAction *action,
     return FALSE;
 
   gtk_entry_get_icon_area (gtk_entry, icon->pos, &icon_area);
-  memset (&event, 0, sizeof (event));
-  event.any.type = GDK_BUTTON_PRESS;
-  event.any.window = gtk_widget_get_window (widget);
-  event.button.button = 1;
-  event.any.send_event = TRUE;
-  event.button.time = GDK_CURRENT_TIME;
-  event.button.x = icon_area.x;
-  event.button.y = icon_area.y;
-
-  g_signal_emit_by_name (widget, "icon-press", 0, icon->pos, &event);
+
+  event = gdk_event_new (GDK_BUTTON_PRESS);
+  event->any.window = g_object_ref (gtk_widget_get_window (widget));
+  event->button.button = 1;
+  event->any.send_event = TRUE;
+  event->button.time = GDK_CURRENT_TIME;
+  event->button.x = icon_area.x;
+  event->button.y = icon_area.y;
+
+  g_signal_emit_by_name (widget, "icon-press", 0, icon->pos, event);
+  gdk_event_free (event);
   return TRUE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]