iOS: Fix freeze when stopping application

The target of the connection determines in which thread the slot is
executed, and in these cases the slot needs to be executed in the
logging thread. But the LogTailFiles object is created and stays on the
main thread. So, the slot that was supposed to stop the event loop in
the logging thread was blocked from being executed when
IosToolHanderPrivate waited for the canceled threads to finish with
futureSynchronizer.waitForFinished().

Use the event loop as the "target" of the connections.

Amends 33e8251edf

Change-Id: Ie78fcb33b88c1fe7a138fac790fd4f3b7dd9bad9
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Eike Ziller
2023-03-13 09:50:15 +01:00
parent 05d9742a96
commit 425262ce7e

View File

@@ -72,14 +72,12 @@ public:
// The future is canceled when app on simulator is stoped.
QEventLoop loop;
QFutureWatcher<void> watcher;
connect(&watcher, &QFutureWatcher<void>::canceled, this, [&] {
loop.quit();
});
connect(&watcher, &QFutureWatcher<void>::canceled, &loop, [&] { loop.quit(); });
watcher.setFuture(fi.future());
// Process to print the console output while app is running.
auto logProcess = [this, fi](QProcess *tailProcess, std::shared_ptr<QTemporaryFile> file) {
QObject::connect(tailProcess, &QProcess::readyReadStandardOutput, this, [=] {
auto logProcess = [&](QProcess *tailProcess, std::shared_ptr<QTemporaryFile> file) {
QObject::connect(tailProcess, &QProcess::readyReadStandardOutput, &loop, [=] {
if (!fi.isCanceled())
emit logMessage(QString::fromLocal8Bit(tailProcess->readAll()));
});