Merge lp:~3v1n0/ido/parent-signals-disconnection-trusty into lp:ido/14.04

Proposed by Marco Trevisan (Treviño) on 2017-04-03
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2017-04-03
Approved revision: 187
Merged at revision: 187
Proposed branch: lp:~3v1n0/ido/parent-signals-disconnection-trusty
Merge into: lp:ido/14.04
Diff against target: 136 lines (+48/-8)
2 files modified
debian/changelog (+7/-0)
src/idocalendarmenuitem.c (+41/-8)
To merge this branch: bzr merge lp:~3v1n0/ido/parent-signals-disconnection-trusty
Reviewer Review Type Date Requested Status
Indicator Applet Developers 2017-04-03 Pending
Review via email: mp+321735@code.launchpad.net

Commit message

IdoCalendarMenuItem: disconnect from parent signals on item destruction

To post a comment you must log in.
Marco Trevisan (Treviño) (3v1n0) wrote :

Self-approving as they're the PRs with same code already landed in 16.04 and upstream.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-10-21 15:52:32 +0000
3+++ debian/changelog 2017-04-03 16:06:58 +0000
4@@ -1,3 +1,10 @@
5+ido (13.10.0+14.04.20151021-0ubuntu2) UNRELEASED; urgency=medium
6+
7+ * IdoCalendarMenuItem: disconnect from parent signals on item
8+ destruction (LP: #1506427)
9+
10+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Mon, 03 Apr 2017 23:58:23 +0800
11+
12 ido (13.10.0+14.04.20151021-0ubuntu1) trusty; urgency=medium
13
14 * IdoCalendarMenuItem: add crash guard on
15
16=== modified file 'src/idocalendarmenuitem.c'
17--- src/idocalendarmenuitem.c 2015-10-15 11:23:52 +0000
18+++ src/idocalendarmenuitem.c 2017-04-03 16:06:58 +0000
19@@ -28,8 +28,9 @@
20 #include "idocalendarmenuitem.h"
21 #include "config.h"
22
23-static void ido_calendar_menu_item_select (GtkMenuItem *item);
24-static void ido_calendar_menu_item_deselect (GtkMenuItem *item);
25+static void ido_calendar_menu_item_finalize (GObject *item);
26+static void ido_calendar_menu_item_select (GtkMenuItem *item);
27+static void ido_calendar_menu_item_deselect (GtkMenuItem *item);
28 static gboolean ido_calendar_menu_item_button_release (GtkWidget *widget,
29 GdkEventButton *event);
30 static gboolean ido_calendar_menu_item_button_press (GtkWidget *widget,
31@@ -54,6 +55,7 @@
32 {
33 GtkWidget *box;
34 GtkWidget *calendar;
35+ GtkWidget *parent;
36 gboolean selected;
37 };
38
39@@ -72,6 +74,8 @@
40 widget_class = GTK_WIDGET_CLASS (klass);
41 menu_item_class = GTK_MENU_ITEM_CLASS (klass);
42
43+ gobject_class->finalize = ido_calendar_menu_item_finalize;
44+
45 widget_class->button_release_event = ido_calendar_menu_item_button_release;
46 widget_class->button_press_event = ido_calendar_menu_item_button_press;
47
48@@ -81,12 +85,12 @@
49 menu_item_class->hide_on_activate = TRUE;
50
51 g_type_class_add_private (gobject_class, sizeof (IdoCalendarMenuItemPrivate));
52-
53+
54 g_signal_new("month-changed", G_TYPE_FROM_CLASS(klass),
55 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
56 g_cclosure_marshal_VOID__VOID,
57 G_TYPE_NONE, 0);
58-
59+
60 g_signal_new("day-selected", G_TYPE_FROM_CLASS(klass),
61 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
62 g_cclosure_marshal_VOID__VOID,
63@@ -107,6 +111,8 @@
64 /* Will be disposed automatically */
65 priv->calendar = g_object_new (gtk_calendar_get_type (),
66 NULL);
67+ g_object_add_weak_pointer (G_OBJECT (priv->calendar),
68+ (gpointer*) &priv->calendar);
69
70 g_signal_connect (priv->calendar,
71 "realize",
72@@ -127,6 +133,29 @@
73 }
74
75 static void
76+ido_calendar_menu_item_finalize (GObject *object)
77+{
78+ IdoCalendarMenuItem *item = IDO_CALENDAR_MENU_ITEM (object);
79+ IdoCalendarMenuItemPrivate *priv = IDO_CALENDAR_MENU_ITEM_GET_PRIVATE (item);
80+
81+ if (G_IS_OBJECT (priv->calendar))
82+ {
83+ g_object_remove_weak_pointer (G_OBJECT (priv->calendar),
84+ (gpointer*) &priv->calendar);
85+ g_signal_handlers_disconnect_by_data (priv->calendar, item);
86+ }
87+
88+ if (G_IS_OBJECT (priv->parent))
89+ {
90+ g_object_remove_weak_pointer (G_OBJECT (priv->parent),
91+ (gpointer*) &priv->parent);
92+ g_signal_handlers_disconnect_by_data (priv->parent, item);
93+ }
94+
95+ G_OBJECT_CLASS (ido_calendar_menu_item_parent_class)->finalize (object);
96+}
97+
98+static void
99 ido_calendar_menu_item_send_focus_change (GtkWidget *widget,
100 gboolean in)
101 {
102@@ -258,7 +287,6 @@
103 ido_calendar_menu_item_send_focus_change (GTK_WIDGET (IDO_CALENDAR_MENU_ITEM (item)->priv->calendar), FALSE);
104 }
105
106-
107 static void
108 calendar_realized_cb (GtkWidget *widget,
109 IdoCalendarMenuItem *item)
110@@ -268,11 +296,16 @@
111 gdk_window_raise (gtk_widget_get_window (widget));
112 }
113
114- g_signal_connect (gtk_widget_get_parent (GTK_WIDGET (item)),
115+ item->priv->parent = gtk_widget_get_parent (GTK_WIDGET (item));
116+
117+ g_object_add_weak_pointer (G_OBJECT (item->priv->parent),
118+ (gpointer*) &item->priv->parent);
119+
120+ g_signal_connect (item->priv->parent,
121 "key-press-event",
122 G_CALLBACK (ido_calendar_menu_item_key_press),
123 item);
124-
125+
126 g_signal_connect (item->priv->calendar,
127 "month-changed",
128 G_CALLBACK (calendar_month_changed_cb),
129@@ -285,7 +318,7 @@
130 "day-selected-double-click",
131 G_CALLBACK (calendar_day_selected_double_click_cb),
132 item);
133-
134+
135 ido_calendar_menu_item_send_focus_change (widget, TRUE);
136 }
137

Subscribers

People subscribed via source and target branches