[gnome-builder] runner: allow marking a runner as failed
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] runner: allow marking a runner as failed
- Date: Wed, 22 Mar 2017 22:00:12 +0000 (UTC)
commit 3238c0153eb824b0044c3d821eb934a474688e7f
Author: Christian Hergert <chergert redhat com>
Date: Wed Mar 22 14:59:27 2017 -0700
runner: allow marking a runner as failed
libide/runner/ide-run-manager.c | 13 +++++++++
libide/runner/ide-runner.c | 58 +++++++++++++++++++++++++++++++++++++++
libide/runner/ide-runner.h | 3 ++
3 files changed, 74 insertions(+), 0 deletions(-)
---
diff --git a/libide/runner/ide-run-manager.c b/libide/runner/ide-run-manager.c
index c5d7ad4..549692d 100644
--- a/libide/runner/ide-run-manager.c
+++ b/libide/runner/ide-run-manager.c
@@ -302,6 +302,8 @@ do_run_async (IdeRunManager *self,
g_autoptr(IdeRunner) runner = NULL;
GCancellable *cancellable;
+ IDE_ENTRY;
+
g_assert (IDE_IS_RUN_MANAGER (self));
g_assert (G_IS_TASK (task));
@@ -341,10 +343,21 @@ do_run_async (IdeRunManager *self,
g_signal_emit (self, signals [RUN], 0, runner);
+ if (ide_runner_get_failed (runner))
+ {
+ g_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "Failed to execute the application");
+ IDE_EXIT;
+ }
+
ide_runner_run_async (runner,
cancellable,
ide_run_manager_run_cb,
g_object_ref (task));
+
+ IDE_EXIT;
}
static void
diff --git a/libide/runner/ide-runner.c b/libide/runner/ide-runner.c
index cd7c56e..5aef874 100644
--- a/libide/runner/ide-runner.c
+++ b/libide/runner/ide-runner.c
@@ -49,6 +49,7 @@ typedef struct
int tty_fd;
guint clear_env : 1;
+ guint failed : 1;
guint run_on_host : 1;
} IdeRunnerPrivate;
@@ -69,6 +70,7 @@ enum {
PROP_ARGV,
PROP_CLEAR_ENV,
PROP_ENV,
+ PROP_FAILED,
PROP_RUN_ON_HOST,
N_PROPS
};
@@ -463,6 +465,10 @@ ide_runner_get_property (GObject *object,
g_value_set_object (value, ide_runner_get_environment (self));
break;
+ case PROP_FAILED:
+ g_value_set_boolean (value, ide_runner_get_failed (self));
+ break;
+
case PROP_RUN_ON_HOST:
g_value_set_boolean (value, ide_runner_get_run_on_host (self));
break;
@@ -490,6 +496,10 @@ ide_runner_set_property (GObject *object,
ide_runner_set_clear_env (self, g_value_get_boolean (value));
break;
+ case PROP_FAILED:
+ ide_runner_set_failed (self, g_value_get_boolean (value));
+ break;
+
case PROP_RUN_ON_HOST:
ide_runner_set_run_on_host (self, g_value_get_boolean (value));
break;
@@ -535,6 +545,27 @@ ide_runner_class_init (IdeRunnerClass *klass)
IDE_TYPE_ENVIRONMENT,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ /**
+ * IdeRunner:failed:
+ *
+ * If the runner has "failed". This should be set if a plugin can determine
+ * that the runner cannot be executed due to an external issue. One such
+ * example might be a debugger plugin that cannot locate a suitable debugger
+ * to run the program.
+ */
+ properties [PROP_FAILED] =
+ g_param_spec_boolean ("failed",
+ "Failed",
+ "If the runner has failed",
+ FALSE,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * IdeRunner:run-on-host:
+ *
+ * The "run-on-host" property indicates the program should be run on the
+ * host machine rather than inside the application sandbox.
+ */
properties [PROP_RUN_ON_HOST] =
g_param_spec_boolean ("run-on-host",
"Run on Host",
@@ -1132,3 +1163,30 @@ ide_runner_get_runtime (IdeRunner *self)
return config != NULL ? g_object_ref (config) : NULL;
}
+
+gboolean
+ide_runner_get_failed (IdeRunner *self)
+{
+ IdeRunnerPrivate *priv = ide_runner_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_RUNNER (self), FALSE);
+
+ return priv->failed;
+}
+
+void
+ide_runner_set_failed (IdeRunner *self,
+ gboolean failed)
+{
+ IdeRunnerPrivate *priv = ide_runner_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_RUNNER (self));
+
+ failed = !!failed;
+
+ if (failed != priv->failed)
+ {
+ priv->failed = failed;
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_FAILED]);
+ }
+}
diff --git a/libide/runner/ide-runner.h b/libide/runner/ide-runner.h
index fb60484..b64a3b7 100644
--- a/libide/runner/ide-runner.h
+++ b/libide/runner/ide-runner.h
@@ -62,6 +62,9 @@ struct _IdeRunnerClass
};
IdeRunner *ide_runner_new (IdeContext *context);
+gboolean ide_runner_get_failed (IdeRunner *self);
+void ide_runner_set_failed (IdeRunner *self,
+ gboolean failed);
IdeRuntime *ide_runner_get_runtime (IdeRunner *self);
void ide_runner_force_quit (IdeRunner *self);
IdeEnvironment *ide_runner_get_environment (IdeRunner *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]