summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@igalia.com>2019-07-02 12:16:43 -0500
committerMichael Catanzaro <mcatanzaro@igalia.com>2019-07-03 16:09:42 -0500
commitd87152f0327d8a6ba28ca7eb5f629d9becca0c4c (patch)
treed74fb6a0c7057bf0cb43b6d11ddda6ce6bad232b
parent008055bf79f7632a301c61154f2dd6cd1d299725 (diff)
downloadgnome-calendar-mcatanzaro/rbz-1509551.tar.gz
Try to fix a crash in update_default_calendar_row()mcatanzaro/rbz-1509551
This function is crashing in 3.32 because the manager object is invalid. I think there are two related bugs: First, it looks like gcal_quick_add_popover_set_property() is failing to disconnect its signals from the old GcalManager before setting the new one. In one backtrace, I see the GcalManager emitting the signal is different than the GcalQuickAddPopover's current manager, which is surely unintended. But that shouldn't be enough to crash on its own, since the GcalQuickAddPopover should still have a valid manager, even if not the intended one. So I suspect the GcalQuickAddPopover itself is invalid at this point. (The crash occured for me after adding an event, so it was probably just destroyed.) GcalQuickAddPopover is not disconnecting these signals in dispose, which is unsafe. We can avoid the need to do so by using g_signal_connect_object(). Now in master, the GcalManager is now owned indirectly by the GcalContext, but the underlying problems from the 3.32 crash are all still here. This attempts to fix them. The fix is speculative, but it's surely safer than the original code. Fixes #416, fixes #418, fixes #420, and fixes #392. Probably fixes a lot more. Who knows. https://bugzilla.redhat.com/show_bug.cgi?id=1509551
-rw-r--r--src/gui/gcal-quick-add-popover.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/gui/gcal-quick-add-popover.c b/src/gui/gcal-quick-add-popover.c
index a1d7a4cf..4f8e93e5 100644
--- a/src/gui/gcal-quick-add-popover.c
+++ b/src/gui/gcal-quick-add-popover.c
@@ -782,12 +782,20 @@ gcal_quick_add_popover_set_property (GObject *object,
break;
case PROP_CONTEXT:
- if (g_set_object (&self->context, g_value_get_object (value)))
+ if (self->context != g_value_get_object (value))
{
g_autoptr (GList) calendars = NULL;
GcalManager *manager;
GList *l;
+ if (self->context != NULL)
+ {
+ manager = gcal_context_get_manager (self->context);
+ g_signal_handlers_disconnect_by_data (manager, self);
+ }
+
+ g_set_object (&self->context, g_value_get_object (value));
+
/* Add currently loaded sources */
manager = gcal_context_get_manager (self->context);
calendars = gcal_manager_get_calendars (manager);
@@ -798,10 +806,10 @@ gcal_quick_add_popover_set_property (GObject *object,
g_list_free (calendars);
/* Connect to the manager signals and keep the list updates */
- g_signal_connect (manager, "calendar-added", G_CALLBACK (on_calendar_added), self);
- g_signal_connect (manager, "calendar-changed", G_CALLBACK (on_calendar_changed), self);
- g_signal_connect (manager, "calendar-removed", G_CALLBACK (on_calendar_removed), self);
- g_signal_connect_swapped (manager, "notify::default-calendar", G_CALLBACK (update_default_calendar_row), self);
+ g_signal_connect_object (manager, "calendar-added", G_CALLBACK (on_calendar_added), self, 0);
+ g_signal_connect_object (manager, "calendar-changed", G_CALLBACK (on_calendar_changed), self, 0);
+ g_signal_connect_object (manager, "calendar-removed", G_CALLBACK (on_calendar_removed), self, 0);
+ g_signal_connect_object (manager, "notify::default-calendar", G_CALLBACK (update_default_calendar_row), self, G_CONNECT_SWAPPED);
g_signal_connect_object (self->context,
"notify::time-format",