[devhelp] Window: set sidebar and notebook to NULL in dispose()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] Window: set sidebar and notebook to NULL in dispose()
- Date: Sun, 27 May 2018 08:21:01 +0000 (UTC)
commit 952b0e16b5aa2105e4e9a4df18307da2610257d3
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun May 27 10:14:02 2018 +0200
Window: set sidebar and notebook to NULL in dispose()
Those widgets are added to their containers and DhWindow doesn't keep
explicitly a reference, so when the container is destroyed so is the
widget.
In the unlikely event when a DhWindow function is called after
dispose(), this will prevent ugly crashes (just in case).
src/dh-window.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/src/dh-window.c b/src/dh-window.c
index 4ccdd391..c3c4c964 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -73,13 +73,27 @@ dh_window_delete_event (GtkWidget *widget,
return GTK_WIDGET_CLASS (dh_window_parent_class)->delete_event (widget, event);
}
+static void
+dh_window_dispose (GObject *object)
+{
+ DhWindowPrivate *priv = dh_window_get_instance_private (DH_WINDOW (object));
+
+ priv->sidebar = NULL;
+ priv->notebook = NULL;
+
+ G_OBJECT_CLASS (dh_window_parent_class)->dispose (object);
+}
+
static void
dh_window_class_init (DhWindowClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
widget_class->delete_event = dh_window_delete_event;
+ object_class->dispose = dh_window_dispose;
+
/* Bind class to template */
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/devhelp/dh-window.ui");
gtk_widget_class_bind_template_child_private (widget_class, DhWindow, header_bar);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]