[gnome-builder] run-manager: add cancellation chains
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] run-manager: add cancellation chains
- Date: Mon, 18 Dec 2017 23:27:51 +0000 (UTC)
commit 714eed85fd311201dbec51d24d670feb3102fc46
Author: Christian Hergert <chergert redhat com>
Date: Mon Dec 18 15:24:05 2017 -0800
run-manager: add cancellation chains
Now that we have dzl_cancellable_chain(), we can use an internal
cancellable and chain that onto user provided cancellables.
src/libide/runner/ide-run-manager.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/libide/runner/ide-run-manager.c b/src/libide/runner/ide-run-manager.c
index 3b2959a..dacd409 100644
--- a/src/libide/runner/ide-run-manager.c
+++ b/src/libide/runner/ide-run-manager.c
@@ -640,14 +640,16 @@ ide_run_manager_run_async (IdeRunManager *self,
g_return_if_fail (IDE_IS_RUN_MANAGER (self));
g_return_if_fail (!build_target || IDE_IS_BUILD_TARGET (build_target));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+ g_return_if_fail (!g_cancellable_is_cancelled (self->cancellable));
if (cancellable == NULL)
cancellable = local_cancellable = g_cancellable_new ();
+ dzl_cancellable_chain (cancellable, self->cancellable);
+
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_run_manager_run_async);
-
- g_set_object (&self->cancellable, cancellable);
+ g_task_set_priority (task, G_PRIORITY_LOW);
if (ide_run_manager_check_busy (self, &error))
{
@@ -703,7 +705,8 @@ ide_run_manager_cancel (IdeRunManager *self)
g_return_if_fail (IDE_IS_RUN_MANAGER (self));
if (self->cancellable != NULL)
- g_timeout_add (0, do_cancel_in_timeout, g_object_ref (self->cancellable));
+ g_timeout_add (0, do_cancel_in_timeout, g_steal_pointer (&self->cancellable));
+ self->cancellable = g_cancellable_new ();
IDE_EXIT;
}
@@ -1102,6 +1105,8 @@ ide_run_manager_actions_stop (IdeRunManager *self,
static void
ide_run_manager_init (IdeRunManager *self)
{
+ self->cancellable = g_cancellable_new ();
+
ide_run_manager_add_handler (self,
"run",
_("Run"),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]