[gnome-calendar/gnome-3-34] Fix GcalContext management
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/gnome-3-34] Fix GcalContext management
- Date: Sat, 5 Oct 2019 14:10:24 +0000 (UTC)
commit b811d93ad09a0c96cebcb5ff51ab8d60e4ac30cf
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Oct 4 20:54:05 2019 -0300
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
.../gcal-calendar-management-dialog.c | 1 -
src/gui/gcal-edit-dialog.c | 1 +
src/gui/gcal-quick-add-popover.c | 12 +++++------
src/gui/gcal-window.c | 25 +++++++++++-----------
src/views/gcal-month-view.c | 3 +--
src/views/gcal-view.c | 2 +-
src/views/gcal-week-view.c | 3 +--
src/views/gcal-year-view.c | 3 +--
src/weather/gcal-weather-settings.c | 14 ++++++------
9 files changed, 29 insertions(+), 35 deletions(-)
---
diff --git a/src/gui/calendar-management/gcal-calendar-management-dialog.c
b/src/gui/calendar-management/gcal-calendar-management-dialog.c
index 754723ac..b151e026 100644
--- a/src/gui/calendar-management/gcal-calendar-management-dialog.c
+++ b/src/gui/calendar-management/gcal-calendar-management-dialog.c
@@ -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:
diff --git a/src/gui/gcal-edit-dialog.c b/src/gui/gcal-edit-dialog.c
index b66047a8..a808d538 100644
--- a/src/gui/gcal-edit-dialog.c
+++ b/src/gui/gcal-edit-dialog.c
@@ -1205,6 +1205,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",
diff --git a/src/gui/gcal-quick-add-popover.c b/src/gui/gcal-quick-add-popover.c
index 34d97ed1..4f638637 100644
--- a/src/gui/gcal-quick-add-popover.c
+++ b/src/gui/gcal-quick-add-popover.c
@@ -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");
diff --git a/src/gui/gcal-window.c b/src/gui/gcal-window.c
index c35e617d..993d3604 100644
--- a/src/gui/gcal-window.c
+++ b/src/gui/gcal-window.c
@@ -867,15 +867,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;
}
@@ -907,16 +907,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:
@@ -1023,7 +1022,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",
diff --git a/src/views/gcal-month-view.c b/src/views/gcal-month-view.c
index cde8062b..459173c2 100644
--- a/src/views/gcal-month-view.c
+++ b/src/views/gcal-month-view.c
@@ -2182,6 +2182,7 @@ gcal_month_view_set_property (GObject *object,
break;
case PROP_CONTEXT:
+ g_assert (self->context == NULL);
self->context = g_value_dup_object (value);
for (i = 0; i < 42; i++)
@@ -2199,8 +2200,6 @@ gcal_month_view_set_property (GObject *object,
self,
0);
update_weather (self, TRUE);
-
- g_object_notify (object, "context");
break;
default:
diff --git a/src/views/gcal-view.c b/src/views/gcal-view.c
index c5b0bf50..8894c53a 100644
--- a/src/views/gcal-view.c
+++ b/src/views/gcal-view.c
@@ -54,7 +54,7 @@ gcal_view_default_init (GcalViewInterface *iface)
"The context",
"The context of the view",
GCAL_TYPE_CONTEXT,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS));
/**
* GcalView::create-event:
diff --git a/src/views/gcal-week-view.c b/src/views/gcal-week-view.c
index 9d9b7111..16928a30 100644
--- a/src/views/gcal-week-view.c
+++ b/src/views/gcal-week-view.c
@@ -570,6 +570,7 @@ gcal_week_view_set_property (GObject *object,
break;
case PROP_CONTEXT:
+ g_assert (self->context == NULL);
self->context = g_value_dup_object (value);
gcal_week_grid_set_context (GCAL_WEEK_GRID (self->week_grid), self->context);
@@ -580,8 +581,6 @@ gcal_week_view_set_property (GObject *object,
G_CALLBACK (gtk_widget_queue_draw),
self->hours_bar,
G_CONNECT_SWAPPED);
-
- g_object_notify (object, "context");
break;
default:
diff --git a/src/views/gcal-year-view.c b/src/views/gcal-year-view.c
index 30b80482..43e8b1b6 100644
--- a/src/views/gcal-year-view.c
+++ b/src/views/gcal-year-view.c
@@ -1744,6 +1744,7 @@ gcal_year_view_set_property (GObject *object,
break;
case PROP_CONTEXT:
+ g_assert (self->context == NULL);
self->context = g_value_dup_object (value);
g_signal_connect_object (gcal_context_get_clock (self->context),
@@ -1758,8 +1759,6 @@ gcal_year_view_set_property (GObject *object,
self,
0);
update_weather (self);
-
- g_object_notify (object, "context");
break;
case PROP_SHOW_WEEK_NUMBERS:
diff --git a/src/weather/gcal-weather-settings.c b/src/weather/gcal-weather-settings.c
index dd17df7d..6d122bfd 100644
--- a/src/weather/gcal-weather-settings.c
+++ b/src/weather/gcal-weather-settings.c
@@ -313,14 +313,12 @@ gcal_weather_settings_set_property (GObject *object,
switch (prop_id)
{
case PROP_CONTEXT:
- if (g_set_object (&self->context, g_value_get_object (value)))
- {
- load_weather_settings (self);
- update_menu_weather_sensitivity (self);
- manage_weather_service (self);
+ g_assert (self->context == NULL);
+ self->context = g_value_dup_object (value);
- g_object_notify_by_pspec (object, properties[PROP_CONTEXT]);
- }
+ load_weather_settings (self);
+ update_menu_weather_sensitivity (self);
+ manage_weather_service (self);
break;
default:
@@ -342,7 +340,7 @@ gcal_weather_settings_class_init (GcalWeatherSettingsClass *klass)
"Context",
"Context",
GCAL_TYPE_CONTEXT,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]