[gnome-builder] plugins/terminal: keep signal handler id for disconnect
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/terminal: keep signal handler id for disconnect
- Date: Sat, 13 Aug 2022 04:36:01 +0000 (UTC)
commit 46f47906c51ebdf2a40278e4c96c68e86453af2b
Author: Christian Hergert <chergert redhat com>
Date: Fri Aug 12 21:33:07 2022 -0700
plugins/terminal: keep signal handler id for disconnect
It's nice to disconnect the exact handler we added without having to
match, so just keep the handler and the run manager instance around until
cleanup.
Also fixes a g_critical() at shutdown.
.../terminal/gbp-terminal-workspace-addin.c | 44 +++++++++++-----------
1 file changed, 21 insertions(+), 23 deletions(-)
---
diff --git a/src/plugins/terminal/gbp-terminal-workspace-addin.c
b/src/plugins/terminal/gbp-terminal-workspace-addin.c
index b0e51c716..3592e6283 100644
--- a/src/plugins/terminal/gbp-terminal-workspace-addin.c
+++ b/src/plugins/terminal/gbp-terminal-workspace-addin.c
@@ -36,6 +36,10 @@ struct _GbpTerminalWorkspaceAddin
{
GObject parent_instance;
+ IdeRunManager *run_manager;
+ gulong run_manager_run_handler;
+ gulong run_manager_stopped_handler;
+
IdeWorkspace *workspace;
IdePane *app_pane;
@@ -291,16 +295,19 @@ gbp_terminal_workspace_addin_load (IdeWorkspaceAddin *addin,
NULL);
ide_workspace_add_pane (workspace, self->app_pane, position);
- g_signal_connect_object (run_manager,
- "run",
- G_CALLBACK (on_run_manager_run),
- self,
- G_CONNECT_SWAPPED);
- g_signal_connect_object (run_manager,
- "stopped",
- G_CALLBACK (on_run_manager_stopped),
- self,
- G_CONNECT_SWAPPED);
+ g_set_object (&self->run_manager, run_manager);
+ self->run_manager_run_handler =
+ g_signal_connect_object (self->run_manager,
+ "run",
+ G_CALLBACK (on_run_manager_run),
+ self,
+ G_CONNECT_SWAPPED);
+ self->run_manager_stopped_handler =
+ g_signal_connect_object (self->run_manager,
+ "stopped",
+ G_CALLBACK (on_run_manager_stopped),
+ self,
+ G_CONNECT_SWAPPED);
}
}
@@ -309,26 +316,17 @@ gbp_terminal_workspace_addin_unload (IdeWorkspaceAddin *addin,
IdeWorkspace *workspace)
{
GbpTerminalWorkspaceAddin *self = (GbpTerminalWorkspaceAddin *)addin;
- IdeWorkbench *workbench;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_TERMINAL_WORKSPACE_ADDIN (self));
g_assert (IDE_IS_PRIMARY_WORKSPACE (workspace) ||
IDE_IS_EDITOR_WORKSPACE (workspace));
- workbench = ide_widget_get_workbench (GTK_WIDGET (workspace));
-
- if (ide_workbench_has_project (workbench))
+ if (self->run_manager)
{
- IdeContext *context = ide_widget_get_context (GTK_WIDGET (workspace));
- IdeRunManager *run_manager = ide_run_manager_from_context (context);
-
- g_signal_handlers_disconnect_by_func (run_manager,
- G_CALLBACK (on_run_manager_run),
- self);
- g_signal_handlers_disconnect_by_func (run_manager,
- G_CALLBACK (on_run_manager_stopped),
- self);
+ g_clear_signal_handler (&self->run_manager_run_handler, self->run_manager);
+ g_clear_signal_handler (&self->run_manager_stopped_handler, self->run_manager);
+ g_clear_object (&self->run_manager);
}
self->app_page = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]