[gnome-calendar] views: simplify reference leak workaround
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] views: simplify reference leak workaround
- Date: Sat, 16 Dec 2017 23:50:22 +0000 (UTC)
commit d283316382e5f7408d1c1776511e1df7672f656d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Dec 16 21:49:22 2017 -0200
views: simplify reference leak workaround
Oh so many unecessary casts =(
src/views/gcal-month-view.c | 13 ++++---------
src/views/gcal-year-view.c | 17 ++++++-----------
2 files changed, 10 insertions(+), 20 deletions(-)
---
diff --git a/src/views/gcal-month-view.c b/src/views/gcal-month-view.c
index 79a9e525..9355b168 100644
--- a/src/views/gcal-month-view.c
+++ b/src/views/gcal-month-view.c
@@ -162,8 +162,6 @@ enum
N_PROPS
};
-static gpointer month_view_parent_class = NULL;
-
/*
* Auxiliary functions
@@ -1825,7 +1823,7 @@ gcal_month_view_destroyed (GtkWidget *widget)
g_clear_object (&self->weather_service);
}
- GTK_WIDGET_CLASS (month_view_parent_class)->destroy ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self,
GTK_TYPE_GRID, GtkGrid));
+ GTK_WIDGET_CLASS (gcal_month_view_parent_class)->destroy (widget);
}
static void
@@ -2197,6 +2195,9 @@ gcal_month_view_class_init (GcalMonthViewClass *klass)
widget_class->key_press_event = gcal_month_view_key_press;
widget_class->scroll_event = gcal_month_view_scroll_event;
+ /* FIXME: Hack to deal with broken reference counts */
+ widget_class->destroy = gcal_month_view_destroyed;
+
container_class = GTK_CONTAINER_CLASS (klass);
container_class->add = gcal_month_view_add;
container_class->remove = gcal_month_view_remove;
@@ -2206,8 +2207,6 @@ gcal_month_view_class_init (GcalMonthViewClass *klass)
g_object_class_override_property (object_class, PROP_MANAGER, "manager");
g_object_class_override_property (object_class, PROP_WEATHER_SERVICE, "weather-service");
-
-
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/month-view.ui");
gtk_widget_class_bind_template_child (widget_class, GcalMonthView, label_0);
@@ -2225,10 +2224,6 @@ gcal_month_view_class_init (GcalMonthViewClass *klass)
gtk_widget_class_set_css_name (widget_class, "calendar-view");
g_type_ensure (GCAL_TYPE_MONTH_POPOVER);
-
- /* FIXME: Hack to deal with broken reference counts */
- month_view_parent_class = g_type_class_peek_parent (klass);
- ((GtkWidgetClass *) klass)->destroy = (void (*) (GtkWidget *)) gcal_month_view_destroyed;
}
static void
diff --git a/src/views/gcal-year-view.c b/src/views/gcal-year-view.c
index ae1386ee..51483ab8 100644
--- a/src/views/gcal-year-view.c
+++ b/src/views/gcal-year-view.c
@@ -130,8 +130,6 @@ enum {
LAST_PROP
};
-static gpointer year_view_parent_class = NULL;
-
static void gcal_view_interface_init (GcalViewInterface *iface);
static void gcal_data_model_subscriber_interface_init (ECalDataModelSubscriberInterface *iface);
static void update_weather (GcalYearView *self);
@@ -1611,15 +1609,13 @@ gcal_year_view_destroyed (GtkWidget *widget)
{
GcalYearView *self = GCAL_YEAR_VIEW (widget);
- if (self->weather_service != NULL)
+ if (self->weather_service)
{
- g_signal_handlers_disconnect_by_func (self->weather_service,
- (GCallback) weather_changed,
- self);
+ g_signal_handlers_disconnect_by_func (self->weather_service, weather_changed, self);
g_clear_object (&self->weather_service);
}
- GTK_WIDGET_CLASS (year_view_parent_class)->destroy ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self,
GTK_TYPE_BOX, GtkGrid));
+ GTK_WIDGET_CLASS (gcal_year_view_parent_class)->destroy (widget);
}
static void
@@ -1990,6 +1986,9 @@ gcal_year_view_class_init (GcalYearViewClass *klass)
widget_class->size_allocate = gcal_year_view_size_allocate;
widget_class->direction_changed = gcal_year_view_direction_changed;
+ /* Hack to deal with broken reference counts */
+ widget_class->destroy = gcal_year_view_destroyed;
+
g_object_class_override_property (object_class, PROP_DATE, "active-date");
g_object_class_override_property (object_class, PROP_MANAGER, "manager");
g_object_class_override_property (object_class, PROP_WEATHER_SERVICE, "weather-service");
@@ -2028,10 +2027,6 @@ gcal_year_view_class_init (GcalYearViewClass *klass)
gtk_widget_class_bind_template_callback (widget_class, popover_closed_cb);
gtk_widget_class_set_css_name (widget_class, "calendar-view");
-
- /* Hack to deal with broken reference counts: */
- year_view_parent_class = g_type_class_peek_parent (klass);
- ((GtkWidgetClass *) klass)->destroy = (void (*) (GtkWidget *)) gcal_year_view_destroyed;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]