[gnome-builder/wip/gtk4-port: 291/343] libide/gui: cleanup workspace disposal
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 291/343] libide/gui: cleanup workspace disposal
- Date: Mon, 4 Apr 2022 20:02:19 +0000 (UTC)
commit 0f7aa3a37b4d3b1eae4dab306dd8b20f1af49a51
Author: Christian Hergert <chergert redhat com>
Date: Fri Apr 1 19:50:44 2022 -0700
libide/gui: cleanup workspace disposal
src/libide/gui/ide-workspace.c | 47 ++++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 18 deletions(-)
---
diff --git a/src/libide/gui/ide-workspace.c b/src/libide/gui/ide-workspace.c
index 8e44984bf..8782455a1 100644
--- a/src/libide/gui/ide-workspace.c
+++ b/src/libide/gui/ide-workspace.c
@@ -203,24 +203,6 @@ ide_workspace_close_request (GtkWindow *window)
return TRUE;
}
-static void
-ide_workspace_dispose (GObject *object)
-{
- IdeWorkspace *self = (IdeWorkspace *)object;
- IdeWorkspacePrivate *priv = ide_workspace_get_instance_private (self);
- GtkWindowGroup *group;
-
- g_assert (IDE_IS_WORKSPACE (self));
-
- ide_clear_and_destroy_object (&priv->addins);
-
- group = gtk_window_get_group (GTK_WINDOW (self));
- if (IDE_IS_WORKBENCH (group))
- ide_workbench_remove_workspace (IDE_WORKBENCH (group), self);
-
- G_OBJECT_CLASS (ide_workspace_parent_class)->dispose (object);
-}
-
/**
* ide_workspace_class_set_kind:
* @klass: a #IdeWorkspaceClass
@@ -356,6 +338,35 @@ ide_workspace_realize (GtkWidget *widget)
gtk_window_maximize (GTK_WINDOW (self));
}
+static void
+ide_workspace_dispose (GObject *object)
+{
+ IdeWorkspace *self = (IdeWorkspace *)object;
+ IdeWorkspacePrivate *priv = ide_workspace_get_instance_private (self);
+ GtkWindowGroup *group;
+
+ g_assert (IDE_IS_WORKSPACE (self));
+
+ /* Unload addins immediately */
+ ide_clear_and_destroy_object (&priv->addins);
+
+ /* Remove the workspace from the workbench MRU/etc */
+ group = gtk_window_get_group (GTK_WINDOW (self));
+ if (IDE_IS_WORKBENCH (group))
+ ide_workbench_remove_workspace (IDE_WORKBENCH (group), self);
+
+ /* Chain up to ensure the GtkWindow cleans up any widgets or other
+ * state attached to the workspace. We keep the context alive during
+ * this process.
+ */
+ G_OBJECT_CLASS (ide_workspace_parent_class)->dispose (object);
+
+ /* A reference is held during this so it is safe to run code after
+ * chaining up to dispose. Force release teh context now.
+ */
+ g_clear_object (&self->context);
+}
+
static void
ide_workspace_finalize (GObject *object)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]