Merge lp:~bregma/libgrip/lp-827958 into lp:libgrip

Proposed by Stephen M. Webb
Status: Merged
Merged at revision: 63
Proposed branch: lp:~bregma/libgrip/lp-827958
Merge into: lp:libgrip
Diff against target: 114 lines (+33/-29)
1 file modified
src/gripgesturemanager.c (+33/-29)
To merge this branch: bzr merge lp:~bregma/libgrip/lp-827958
Reviewer Review Type Date Requested Status
Michael Terry (community) Approve
Sebastien Bacher Pending
Stephen M. Webb Pending
Review via email: mp+78486@code.launchpad.net

This proposal supersedes a proposal from 2011-10-06.

Description of the change

Registers and removes only those widgets whose toplevel was just mapped in the window-mapped callback.

Previously, an attempt to register ALL pending widgets regardless of toplevel was causing an occasional segfault.

To post a comment you must log in.
Revision history for this message
Stephen M. Webb (bregma) wrote : Posted in a previous version of this proposal

A quick re-review of this fix reveals it introduces another bug.

review: Needs Resubmitting
lp:~bregma/libgrip/lp-827958 updated
65. By Stephen M. Webb

Renamed window_mapped_cb to toplevel_mapped_cb to reduce confusion.

Revision history for this message
Stephen M. Webb (bregma) wrote :

NOTE: made a final commit to change the name of the callback function to reduce future confusion.

Revision history for this message
Chase Douglas (chasedouglas) wrote :

The code looks reasonable to me, but I really don't know gtk well enough to approve it myself, especially given how close we are to release. I am have subscribed Michael Terry and Sebastien Bacher to review since they would know more and have commented in the bug report.

As soon as someone with more gtk knowledge approves, I want to get this path added to libgrip and uploaded. I am off until Tuesday, so please work with Seb, Didier, or someone else as appropriate to get it into Oneiric.

Great work figuring this bug out!

Revision history for this message
Michael Terry (mterry) wrote :

So the code changes themselves looks fine. I haven't tested that it fixes the segfault.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/gripgesturemanager.c'
2--- src/gripgesturemanager.c 2011-09-22 19:55:37 +0000
3+++ src/gripgesturemanager.c 2011-10-06 19:41:26 +0000
4@@ -163,9 +163,9 @@
5 GeisSize attr_count,
6 GeisGestureAttr *attrs);
7
8-static void window_mapped_cb (GtkWidget *widget,
9- GdkEvent *event,
10- gpointer user_data);
11+static void toplevel_mapped_cb (GtkWidget *toplevel,
12+ GdkEvent *event,
13+ gpointer user_data);
14
15 static GeisGestureFuncs gesture_funcs = {
16 gesture_added,
17@@ -1253,7 +1253,7 @@
18 GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
19 GripRegistrationRequest *req = (GripRegistrationRequest *)user_data;
20
21- if (GTK_IS_WINDOW (toplevel))
22+ if (gtk_widget_is_toplevel (toplevel))
23 {
24 g_signal_handlers_disconnect_by_func (widget,
25 G_CALLBACK (toplevel_notify_cb),
26@@ -1280,7 +1280,7 @@
27
28 g_signal_connect (toplevel,
29 "map-event",
30- G_CALLBACK (window_mapped_cb),
31+ G_CALLBACK (toplevel_mapped_cb),
32 req->manager);
33 }
34 }
35@@ -1316,7 +1316,7 @@
36 {
37 GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
38
39- if (GTK_IS_WINDOW (toplevel))
40+ if (gtk_widget_is_toplevel (toplevel))
41 {
42 register_internal (manager,
43 widget,
44@@ -1348,35 +1348,39 @@
45 }
46
47 static void
48-window_mapped_cb (GtkWidget *widget,
49- GdkEvent *event G_GNUC_UNUSED,
50- gpointer user_data)
51+toplevel_mapped_cb (GtkWidget *toplevel,
52+ GdkEvent *event G_GNUC_UNUSED,
53+ gpointer user_data)
54 {
55 GripGestureManager *manager = (GripGestureManager *)user_data;
56 GripGestureManagerPrivate *priv = manager->priv;
57- GList *tmp;
58+ GList *request = priv->requests;
59
60- for (tmp = priv->requests; tmp != NULL; tmp = tmp->next)
61+ while (request)
62 {
63- GripRegistrationRequest *req = tmp->data;
64-
65- register_widget (req->manager,
66- req->widget,
67- req->gesture_type,
68- req->device_type,
69- req->touch_points,
70- req->callback,
71- req->user_data,
72- req->destroy);
73-
74- g_free (req);
75+ GList *next = request->next;
76+ GripRegistrationRequest *req = request->data;
77+
78+ if (gtk_widget_get_toplevel (req->widget) == toplevel)
79+ {
80+ register_widget (req->manager,
81+ req->widget,
82+ req->gesture_type,
83+ req->device_type,
84+ req->touch_points,
85+ req->callback,
86+ req->user_data,
87+ req->destroy);
88+
89+ priv->requests = g_list_remove_link (priv->requests, request);
90+ g_free (req);
91+ g_list_free_1 (request);
92+ }
93+ request = next;
94 }
95
96- g_list_free (priv->requests);
97- priv->requests = NULL;
98-
99- g_signal_handlers_disconnect_by_func (widget,
100- window_mapped_cb,
101+ g_signal_handlers_disconnect_by_func (toplevel,
102+ toplevel_mapped_cb,
103 user_data);
104 }
105
106@@ -1445,7 +1449,7 @@
107
108 g_signal_connect (toplevel,
109 "map-event",
110- G_CALLBACK (window_mapped_cb),
111+ G_CALLBACK (toplevel_mapped_cb),
112 manager);
113 }
114 }

Subscribers

People subscribed via source and target branches