summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Weimer <bernd.weimer@qt.io>2021-09-09 10:24:22 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-09-20 19:35:28 +0000
commitd696302e9d521c93802447a9c000e062ed87de42 (patch)
treea0624ee445c108337d1a49099b2bbca6f7240ecb
parent0e6a76de852bdeb694bce69ded42b467235bbc70 (diff)
downloadqtapplicationmanager-d696302e9d521c93802447a9c000e062ed87de42.tar.gz
Fix immediate application restart
A crashing application in the application-features example caused the entire System UI to crash. This reverts commit 6d7c33ea and part of f7506f7b. Change-Id: Idf9cafb15b5e868b7c665269574474aec8a74bf3 Reviewed-by: Robert Griebl <robert.griebl@qt.io> (cherry picked from commit 9211d30bb6639cf46d8d4aa981751ec11996a214) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/manager-lib/applicationmanager.cpp2
-rw-r--r--src/manager-lib/nativeruntime.cpp2
-rw-r--r--src/manager-lib/qmlinprocessruntime.cpp2
-rw-r--r--tests/auto/qml/lifecycle/tst_lifecycle.qml19
4 files changed, 22 insertions, 3 deletions
diff --git a/src/manager-lib/applicationmanager.cpp b/src/manager-lib/applicationmanager.cpp
index 7aff50ce..30405f5f 100644
--- a/src/manager-lib/applicationmanager.cpp
+++ b/src/manager-lib/applicationmanager.cpp
@@ -785,7 +785,7 @@ bool ApplicationManager::startApplicationInternal(const QString &appId, const QS
return false;
}
- connect(runtime, &AbstractRuntime::stateChanged, app, [this, app](Am::RunState newRuntimeState) {
+ connect(runtime, &AbstractRuntime::stateChanged, this, [this, app](Am::RunState newRuntimeState) {
app->setRunState(newRuntimeState);
emit applicationRunStateChanged(app->id(), newRuntimeState);
emitDataChanged(app, QVector<int> { IsRunning, IsStartingUp, IsShuttingDown });
diff --git a/src/manager-lib/nativeruntime.cpp b/src/manager-lib/nativeruntime.cpp
index 5de381fc..5c399048 100644
--- a/src/manager-lib/nativeruntime.cpp
+++ b/src/manager-lib/nativeruntime.cpp
@@ -232,9 +232,9 @@ void NativeRuntime::shutdown(int exitCode, Am::ExitStatus status)
emit finished(exitCode, status);
- setState(Am::NotRunning);
if (m_app)
m_app->setCurrentRuntime(nullptr);
+ setState(Am::NotRunning);
deleteLater();
}
diff --git a/src/manager-lib/qmlinprocessruntime.cpp b/src/manager-lib/qmlinprocessruntime.cpp
index 84946617..9777d257 100644
--- a/src/manager-lib/qmlinprocessruntime.cpp
+++ b/src/manager-lib/qmlinprocessruntime.cpp
@@ -213,9 +213,9 @@ void QmlInProcessRuntime::finish(int exitCode, Am::ExitStatus status)
qCDebug(LogSystem) << "QmlInProcessRuntime (id:" << (m_app ? m_app->id() : qSL("(none)"))
<< ") exited with code:" << exitCode << "status:" << status;
emit finished(exitCode, status);
- setState(Am::NotRunning);
if (m_app)
m_app->setCurrentRuntime(nullptr);
+ setState(Am::NotRunning);
if (m_surfaces.isEmpty())
deleteLater();
diff --git a/tests/auto/qml/lifecycle/tst_lifecycle.qml b/tests/auto/qml/lifecycle/tst_lifecycle.qml
index d75584e2..8af745ce 100644
--- a/tests/auto/qml/lifecycle/tst_lifecycle.qml
+++ b/tests/auto/qml/lifecycle/tst_lifecycle.qml
@@ -131,4 +131,23 @@ TestCase {
while (app.runState !== ApplicationObject.Running)
runStateChangedSpy.wait();
}
+
+ function test_restart() {
+ function onRunstateChanged(id, runState) {
+ if (runState === Am.NotRunning) {
+ ApplicationManager.applicationRunStateChanged.disconnect(onRunstateChanged);
+ ApplicationManager.startApplication(id);
+ }
+ }
+ ApplicationManager.applicationRunStateChanged.connect(onRunstateChanged);
+
+ app.start();
+ while (app.runState !== ApplicationObject.Running)
+ runStateChangedSpy.wait();
+ app.stop();
+ runStateChangedSpy.wait();
+ compare(app.runState, ApplicationObject.ShuttingDown);
+ while (app.runState !== ApplicationObject.Running)
+ runStateChangedSpy.wait();
+ }
}