From 33022eec04a54c8ce87175d79738ea5c0abf7af0 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Sun, 22 Sep 2024 16:36:48 +0300 Subject: [PATCH] Android: fix app termination logging When an app has exited a correct log is printed that it died. However, when the user terminates the app from within Qt Creator, it prints both that the app was terminated and died, that is not correct. This prints only either case when appropriate. Also, slightly rephrase the log message in such cases, and get rid of the starting double new lines which just show up in messed up format with timestamp being separated from the message itself. Change-Id: I211ff1e6d473f1dacc2cd243f64051e81a26a77a Reviewed-by: Jarek Kobus --- src/plugins/android/androidrunner.cpp | 2 +- src/plugins/android/androidrunnerworker.cpp | 11 ++++++++++- src/plugins/android/androidrunnerworker.h | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugins/android/androidrunner.cpp b/src/plugins/android/androidrunner.cpp index a2bcf780b71..fa6dc5a415f 100644 --- a/src/plugins/android/androidrunner.cpp +++ b/src/plugins/android/androidrunner.cpp @@ -110,7 +110,7 @@ void AndroidRunner::stop() return; emit canceled(); - appendMessage("\n\n" + Tr::tr("\"%1\" terminated.").arg(m_packageName), + appendMessage(Tr::tr("Android target \"%1\" terminated.").arg(m_packageName), Utils::NormalMessageFormat); } diff --git a/src/plugins/android/androidrunnerworker.cpp b/src/plugins/android/androidrunnerworker.cpp index e5b68ef975b..abc56ea13a1 100644 --- a/src/plugins/android/androidrunnerworker.cpp +++ b/src/plugins/android/androidrunnerworker.cpp @@ -581,7 +581,10 @@ static ExecutableItem postDoneRecipe(const Storage &storage) const auto onDone = [storage] { storage->m_processPID = -1; storage->m_processUser = -1; - storage->m_glue->setFinished("\n\n" + Tr::tr("\"%1\" died.").arg(storage->m_packageName)); + if (!storage->m_glue->wasCancelled()) { + storage->m_glue->setFinished(Tr::tr("Android target \"%1\" died.") + .arg(storage->m_packageName)); + } }; return Group { @@ -864,6 +867,12 @@ static ExecutableItem pidRecipe(const Storage &storage) }; } +void RunnerInterface::cancel() +{ + m_wasCancelled = true; + emit canceled(); +} + void RunnerInterface::setStarted(const Utils::Port &debugServerPort, const QUrl &qmlServer, qint64 pid) { diff --git a/src/plugins/android/androidrunnerworker.h b/src/plugins/android/androidrunnerworker.h index 4293821f50d..cdf44c7b0f5 100644 --- a/src/plugins/android/androidrunnerworker.h +++ b/src/plugins/android/androidrunnerworker.h @@ -28,9 +28,10 @@ public: ProjectExplorer::RunControl *runControl() const { return m_runControl; } QString deviceSerialNumber() const { return m_deviceSerialNumber; } int apiLevel() const { return m_apiLevel; } + bool wasCancelled() const { return m_wasCancelled; }; // GUI -> business logic - void cancel() { emit canceled(); } + void cancel(); // business logic -> GUI void setStarted(const Utils::Port &debugServerPort, const QUrl &qmlServer, qint64 pid); @@ -51,6 +52,7 @@ signals: private: ProjectExplorer::RunControl *m_runControl = nullptr; QString m_deviceSerialNumber; + bool m_wasCancelled = false; int m_apiLevel = -1; };