summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2024-03-18 13:20:45 +0100
committerRobert Griebl <robert.griebl@qt.io>2024-03-18 16:56:56 +0100
commit41e3f2d42e87fea95a45eef4e9572fdc67bc9a7b (patch)
tree65022059052646b56a86cbc7ec0eaff3587baced
parent0970e3f1d21c6bfaf0e2e6f897b38aa99c4d6f7e (diff)
Fix application quit behavior in single-process mode
Single-process mode QML applications had the finish() callback invoked twice, if a fade-out animation was running on a window. While at it, fixed the 'kill' stop flag to be more in line with the multi-process case and also updated the debug output on application stop to the newer, more readable style used by the native runtime. Change-Id: Iee44526d95b1416b213b897fb2b0542d2535c5e7 Fixes: QTBUG-123420 Pick-to: 6.7 6.6 Reviewed-by: Bernd Weimer <bernd.weimer@qt.io>
-rw-r--r--src/manager-lib/qmlinprocruntime.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/manager-lib/qmlinprocruntime.cpp b/src/manager-lib/qmlinprocruntime.cpp
index eccc3266..ecf9380c 100644
--- a/src/manager-lib/qmlinprocruntime.cpp
+++ b/src/manager-lib/qmlinprocruntime.cpp
@@ -148,7 +148,9 @@ bool QmlInProcRuntime::start()
void QmlInProcRuntime::stop(bool forceKill)
{
setState(Am::ShuttingDown);
- emit aboutToStop();
+
+ if (!forceKill)
+ emit aboutToStop();
for (auto i = m_surfaces.size(); i; --i)
m_surfaces.at(i-1)->setVisibleClientSide(false);
@@ -168,16 +170,39 @@ void QmlInProcRuntime::stop(bool forceKill)
if (!ok || qt < 0)
qt = 250;
QTimer::singleShot(qt, this, [this]() {
- finish(15 /* POSIX SIGTERM */, Am::ForcedExit);
+ if (state() != Am::NotRunning)
+ finish(15 /* POSIX SIGTERM */, Am::ForcedExit);
});
}
void QmlInProcRuntime::finish(int exitCode, Am::ExitStatus status)
{
QMetaObject::invokeMethod(this, [this, exitCode, status]() {
- qCDebug(LogSystem) << "QmlInProcRuntime (id:" << (m_app ? m_app->id() : u"(none)"_s)
- << ") exited with code:" << exitCode << "status:" << status;
- emit finished(exitCode, status);
+ QByteArray cause = "exited";
+ bool printWarning = false;
+ switch (status) {
+ case Am::ForcedExit:
+ cause = "was force exited (" + QByteArray(exitCode == 15 /* POSIX SIGTERM */ ? "terminated" : "killed") + ")";
+ printWarning = true;
+ break;
+ default:
+ if (exitCode != 0) {
+ cause = "exited with code: " + QByteArray::number(exitCode);
+ printWarning = true;
+ }
+ break;
+ }
+
+ if (printWarning) {
+ qCWarning(LogSystem, "In-process runtime for application '%s' %s",
+ (m_app ? qPrintable(m_app->id()) : "<null>"), cause.constData());
+ } else {
+ qCDebug(LogSystem, "In-process runtime for application '%s' %s",
+ (m_app ? qPrintable(m_app->id()) : "<null>"), cause.constData());
+ }
+
+ if (state() != Am::NotRunning)
+ emit finished(exitCode, status);
if (m_app)
m_app->setCurrentRuntime(nullptr);
setState(Am::NotRunning);