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 <jaroslaw.kobus@qt.io>
This commit is contained in:
Assam Boudjelthia
2024-09-22 16:36:48 +03:00
parent d71efc1850
commit 33022eec04
3 changed files with 14 additions and 3 deletions

View File

@@ -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);
}

View File

@@ -581,7 +581,10 @@ static ExecutableItem postDoneRecipe(const Storage<RunnerStorage> &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<RunnerStorage> &storage)
};
}
void RunnerInterface::cancel()
{
m_wasCancelled = true;
emit canceled();
}
void RunnerInterface::setStarted(const Utils::Port &debugServerPort, const QUrl &qmlServer,
qint64 pid)
{

View File

@@ -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;
};