[gnome-calendar/mcatanzaro/rbz-1509551] Try to fix a crash in update_default_calendar_row()
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/mcatanzaro/rbz-1509551] Try to fix a crash in update_default_calendar_row()
- Date: Wed, 3 Jul 2019 04:03:20 +0000 (UTC)
commit 0df7299d8c67628e5b685e14b28d6139a8c5f1d7
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Tue Jul 2 12:16:43 2019 -0500
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().
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.
Probably fixes #416
Probably also fixes #418
https://bugzilla.redhat.com/show_bug.cgi?id=1509551
src/gui/gcal-quick-add-popover.c | 18 +++++++++++++-----
1 file 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",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]