Improve speed of process termination on exit

This commit is contained in:
Cameron Gutman 2019-03-17 12:23:13 -07:00
parent 052194714a
commit 9a6f5ba1a8
2 changed files with 7 additions and 2 deletions

View file

@ -130,8 +130,12 @@ private:
emit computerStateChanged(m_Computer);
}
// Wait a bit to poll again
QThread::sleep(3);
// Wait a bit to poll again, but do it in 100 ms chunks
// so we can be interrupted reasonably quickly.
// FIXME: QWaitCondition would be better.
for (int i = 0; i < 30 && !isInterruptionRequested(); i++) {
QThread::msleep(100);
}
}
}

View file

@ -447,6 +447,7 @@ NvHTTP::openConnection(QUrl baseUrl,
// Run the request with a timeout if requested
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), &loop, SLOT(quit()));
if (timeoutMs) {
QTimer::singleShot(timeoutMs, &loop, SLOT(quit()));
}