[gnome-builder/wip/gtk4-port: 1543/1774] libide/foundry: keep runner around to force exit with signal




commit 798a70f6546bf8ff810de3aaca54024225fb192a
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 15 21:22:11 2022 -0700

    libide/foundry: keep runner around to force exit with signal
    
    This fixes a couple issues with implementation, and now that the
    preference choice is implemented in commit
    31fc9ffde1c22136e2bb0aad955e8213d57744a2 this should be working
    as expected.
    
    Fixes #1685

 src/libide/foundry/ide-run-manager.c | 17 +++++++++++++++++
 src/libide/foundry/ide-runner.c      |  6 +++---
 2 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/libide/foundry/ide-run-manager.c b/src/libide/foundry/ide-run-manager.c
index 1780cc9b7..ae9ce4ddb 100644
--- a/src/libide/foundry/ide-run-manager.c
+++ b/src/libide/foundry/ide-run-manager.c
@@ -61,6 +61,8 @@ struct _IdeRunManager
   const IdeRunHandlerInfo *handler;
   GList                   *handlers;
 
+  IdeRunner               *current_runner;
+
   /* Keep track of last change sequence from the file monitor
    * so that we can maybe skip past install phase and make
    * secondary execution time faster.
@@ -534,6 +536,8 @@ ide_run_manager_run_cb (GObject      *object,
       g_clear_object (&self->notif);
     }
 
+  g_clear_object (&self->current_runner);
+
   if (!ide_runner_run_finish (runner, result, &error))
     ide_task_return_error (task, g_steal_pointer (&error));
   else
@@ -802,6 +806,8 @@ create_runner_cb (GObject      *object,
   ide_notification_set_title (self->notif, title);
   ide_notification_attach (self->notif, IDE_OBJECT (self));
 
+  g_set_object (&self->current_runner, runner);
+
   ide_runner_run_async (runner,
                         cancellable,
                         ide_run_manager_run_cb,
@@ -1143,8 +1149,19 @@ ide_run_manager_cancel (IdeRunManager *self)
 {
   IDE_ENTRY;
 
+  g_return_if_fail (IDE_IS_MAIN_THREAD ());
   g_return_if_fail (IDE_IS_RUN_MANAGER (self));
 
+  /* If the runner is still active, we can just force_exit that instead
+   * of cancelling a bunch of in-flight things. This is more useful since
+   * it means that we can override the exit signal.
+   */
+  if (self->current_runner != NULL)
+    {
+      ide_runner_force_quit (self->current_runner);
+      IDE_EXIT;
+    }
+
   if (self->cancellable != NULL)
     g_timeout_add (0, do_cancel_in_timeout, g_steal_pointer (&self->cancellable));
   self->cancellable = g_cancellable_new ();
diff --git a/src/libide/foundry/ide-runner.c b/src/libide/foundry/ide-runner.c
index 72c2f6863..3aa05b243 100644
--- a/src/libide/foundry/ide-runner.c
+++ b/src/libide/foundry/ide-runner.c
@@ -399,8 +399,8 @@ ide_runner_real_force_quit (IdeRunner *self)
 {
   IdeRunnerPrivate *priv = ide_runner_get_instance_private (self);
   g_autoptr(GSettings) settings = NULL;
+  g_autofree char *stop_signal = NULL;
   IdeContext *context;
-  const char *stop_signal;
   int signum;
 
   IDE_ENTRY;
@@ -410,7 +410,7 @@ ide_runner_real_force_quit (IdeRunner *self)
   if (priv->subprocess == NULL)
     IDE_EXIT;
 
-  if (!priv->sent_force_exit_once)
+  if (priv->sent_force_exit_once)
     {
       ide_subprocess_force_exit (priv->subprocess);
       IDE_EXIT;
@@ -420,7 +420,7 @@ ide_runner_real_force_quit (IdeRunner *self)
 
   context = ide_object_get_context (IDE_OBJECT (self));
   settings = ide_context_ref_project_settings (context);
-  stop_signal = g_settings_get_string (settings, NULL);
+  stop_signal = g_settings_get_string (settings, "stop-signal");
 
   if (0) {}
   else if (ide_str_equal0 (stop_signal, "SIGKILL")) signum = SIGKILL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]