From 5a8fe1f637dbc0dc3db3f0479177435424fffea0 Mon Sep 17 00:00:00 2001
From: Lukas Holecek <hluk@email.cz>
Date: Sun, 28 Mar 2021 09:03:24 +0200
Subject: [PATCH] Wait for commands to finish asynchronously

---
 src/scriptable/scriptable.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/scriptable/scriptable.cpp b/src/scriptable/scriptable.cpp
index 97d0385da..9da8f1d6d 100644
--- a/src/scriptable/scriptable.cpp
+++ b/src/scriptable/scriptable.cpp
@@ -3196,9 +3196,12 @@ bool Scriptable::runAction(Action *action)
     setActionData();
 
     action->setWorkingDirectory( getCurrentPath() );
-    action->start();
 
-    while ( !action->waitForFinished(5000) && canContinue() ) {}
+    QEventLoop loop;
+    connect(action, &Action::actionFinished, &loop, &QEventLoop::quit);
+    connect(this, &Scriptable::finished, &loop, &QEventLoop::quit);
+    action->start();
+    loop.exec();
 
     if ( action->isRunning() && !action->waitForFinished(5000) ) {
         action->terminate();
-- 
GitLab