Blob Blame Raw
From c61ea47874ea92c30b04771c984a3cc4e9e1493b Mon Sep 17 00:00:00 2001
From: Michael Catanzaro <>
Date: Tue, 2 Jul 2019 12:16:43 -0500
Subject: [PATCH] Try to fix a crash in update_default_calendar_row()

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().

Hopefully fixes #416 for the 3.32 branch.
 src/gcal-quick-add-popover.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/gcal-quick-add-popover.c b/src/gcal-quick-add-popover.c
index 59567a62..30b9dc19 100644
--- a/src/gcal-quick-add-popover.c
+++ b/src/gcal-quick-add-popover.c
@@ -778,11 +778,16 @@ gcal_quick_add_popover_set_property (GObject      *object,
     case PROP_MANAGER:
-      if (g_set_object (&self->manager, g_value_get_object (value)))
+      if (self->manager != g_value_get_object (value))
           GcalManager *manager;
           GList *sources, *l;
+          if (self->manager != NULL)
+            g_signal_handlers_disconnect_by_data (self->manager, self);
+          g_set_object (&self->manager, g_value_get_object (value));
           /* Add currently leaded sources */
           manager = self->manager;
           sources = gcal_manager_get_sources_connected (manager);
@@ -793,10 +798,10 @@ gcal_quick_add_popover_set_property (GObject      *object,
           g_list_free (sources);
           /* Connect to the manager signals and keep the list updates */
-          g_signal_connect (manager, "source-added", G_CALLBACK (on_source_added), self);
-          g_signal_connect (manager, "source-changed", G_CALLBACK (on_source_changed), self);
-          g_signal_connect (manager, "source-removed", G_CALLBACK (on_source_removed), self);
-          g_signal_connect_swapped (manager, "notify::default-calendar", G_CALLBACK (update_default_calendar_row), self);
+          g_signal_connect_object (manager, "source-added", G_CALLBACK (on_source_added), self, 0);
+          g_signal_connect_object (manager, "source-changed", G_CALLBACK (on_source_changed), self, 0);
+          g_signal_connect_object (manager, "source-removed", G_CALLBACK (on_source_removed), self, 0);
+          g_signal_connect_object (manager, "notify::default-calendar", G_CALLBACK (update_default_calendar_row), self, G_CONNECT_SWAPPED);
           g_object_notify (G_OBJECT (self), "manager");