Fix GcalContext management

GObject automatically notifies when passing
properties as part of g_object_new(). This
happens after the instance is created, thus
after constructed().

By passing G_PARAM_EXPLICIT_NOTIFY, we avoid
this behavior. However, we are still notifying
PROP_CONTEXT in GcalWindow. Removing this other
notify fixes the crashes related to GcalContext.

https://gitlab.gnome.org/GNOME/gnome-calendar/issues/417
This commit is contained in:
Georges Basile Stavracas Neto
2019-10-04 20:54:05 -03:00
parent a0403b0b3e
commit 357ec18a0a
9 changed files with 29 additions and 35 deletions
@@ -247,7 +247,6 @@ gcal_calendar_management_dialog_set_property (GObject *object,
g_assert (self->context == NULL);
self->context = g_value_dup_object (value);
setup_context (self);
g_object_notify_by_pspec (object, properties[PROP_CONTEXT]);
break;
default:
+1
View File
@@ -1202,6 +1202,7 @@ gcal_edit_dialog_set_property (GObject *object,
break;
case PROP_CONTEXT:
g_assert (self->context == NULL);
self->context = g_value_dup_object (value);
g_signal_connect_object (self->context,
"notify::time-format",
+6 -6
View File
@@ -783,12 +783,14 @@ gcal_quick_add_popover_set_property (GObject *object,
break;
case PROP_CONTEXT:
if (g_set_object (&self->context, g_value_get_object (value)))
{
g_autoptr (GList) calendars = NULL;
GcalManager *manager;
GList *l;
g_assert (self->context == NULL);
self->context = g_value_dup_object (value);
/* Add currently loaded sources */
manager = gcal_context_get_manager (self->context);
calendars = gcal_manager_get_calendars (manager);
@@ -807,8 +809,6 @@ gcal_quick_add_popover_set_property (GObject *object,
G_CALLBACK (update_header),
self,
G_CONNECT_SWAPPED);
g_object_notify (G_OBJECT (self), "context");
}
break;
@@ -889,9 +889,9 @@ gcal_quick_add_popover_class_init (GcalQuickAddPopoverClass *klass)
G_PARAM_READWRITE));
/**
* GcalQuickAddPopover::manager:
* GcalQuickAddPopover::context:
*
* The manager of the application.
* The context of the application.
*/
g_object_class_install_property (object_class,
PROP_CONTEXT,
@@ -899,7 +899,7 @@ gcal_quick_add_popover_class_init (GcalQuickAddPopoverClass *klass)
"Context of the application",
"The singleton context of the application",
GCAL_TYPE_CONTEXT,
G_PARAM_READWRITE));
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/quick-add-popover.ui");
+12 -13
View File
@@ -868,15 +868,15 @@ gcal_window_constructed (GObject *object)
* FIXME: this is a hack around the issue that happens when trying to bind
* these properties using the GtkBuilder .ui file.
*/
g_object_bind_property (self, "context", self->calendar_popover, "context", G_BINDING_DEFAULT);
g_object_bind_property (self, "context", self->calendar_popover, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->weather_settings, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->calendar_management_dialog, "context", G_BINDING_DEFAULT);
g_object_bind_property (self, "context", self->calendar_management_dialog, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->week_view, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->month_view, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->year_view, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->edit_dialog, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->quick_add_popover, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->search_button, "context", G_BINDING_DEFAULT);
g_object_bind_property (self, "context", self->search_button, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
GCAL_EXIT;
}
@@ -908,16 +908,15 @@ gcal_window_set_property (GObject *object,
break;
case PROP_CONTEXT:
if (g_set_object (&self->context, g_value_get_object (value)))
{
g_settings_bind (gcal_context_get_settings (self->context),
"active-view",
self,
"active-view",
G_SETTINGS_BIND_SET | G_SETTINGS_BIND_GET);
g_assert (self->context == NULL);
self->context = g_value_dup_object (value);
g_settings_bind (gcal_context_get_settings (self->context),
"active-view",
self,
"active-view",
G_SETTINGS_BIND_SET | G_SETTINGS_BIND_GET);
g_object_notify_by_pspec (object, properties[PROP_CONTEXT]);
}
break;
default:
@@ -1024,7 +1023,7 @@ gcal_window_class_init (GcalWindowClass *klass)
"Context",
"Context",
GCAL_TYPE_CONTEXT,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
properties[PROP_NEW_EVENT_MODE] = g_param_spec_boolean ("new-event-mode",
"New Event mode",