From b52bded0a77365ac4ba8ce2c968970f4c6635af4 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 23 Jul 2024 06:06:32 +0200 Subject: [PATCH] Android: Don't pass error string Instead, emit remoteProcessFinished() directly from the startDebuggerServer() function. Make this function void. Change-Id: Ibeeb2a1e3aabb9b3021203003e31a7b44eef573e Reviewed-by: Alessandro Portale --- src/plugins/android/androidrunnerworker.cpp | 30 ++++++++------------- src/plugins/android/androidrunnerworker.h | 2 +- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/plugins/android/androidrunnerworker.cpp b/src/plugins/android/androidrunnerworker.cpp index 59e5e4acd0f..45cf40d7abe 100644 --- a/src/plugins/android/androidrunnerworker.cpp +++ b/src/plugins/android/androidrunnerworker.cpp @@ -402,7 +402,7 @@ void AndroidRunnerWorker::setAndroidDeviceInfo(const AndroidDeviceInfo &info) << m_deviceSerialNumber << m_apiLevel; } -void Android::Internal::AndroidRunnerWorker::asyncStartLogcat() +void AndroidRunnerWorker::asyncStartLogcat() { // Its assumed that the device or avd returned by selector() is online. // Start the logcat process before app starts. @@ -555,16 +555,11 @@ void AndroidRunnerWorker::startNativeDebugging() } } } - QString debuggerServerErr; - if (!startDebuggerServer(packageDir, debugServerFile, &debuggerServerErr)) { - emit remoteProcessFinished(debuggerServerErr); - return; - } + startDebuggerServer(packageDir, debugServerFile); } -bool AndroidRunnerWorker::startDebuggerServer(const QString &packageDir, - const QString &debugServerFile, - QString *errorStr) +void AndroidRunnerWorker::startDebuggerServer(const QString &packageDir, + const QString &debugServerFile) { QStringList adbArgs = {"shell", "run-as", m_packageName}; if (m_processUser > 0) @@ -581,9 +576,8 @@ bool AndroidRunnerWorker::startDebuggerServer(const QString &packageDir, if (!m_debugServerProcess) { qCDebug(androidRunWorkerLog) << "Debugger process failed to start" << lldbServerErr; - if (errorStr) - *errorStr = Tr::tr("Failed to start debugger server."); - return false; + emit remoteProcessFinished(Tr::tr("Failed to start debugger server.")); + return; } qCDebug(androidRunWorkerLog) << "Debugger process started"; m_debugServerProcess->setObjectName("AndroidDebugServerProcess"); @@ -601,25 +595,23 @@ bool AndroidRunnerWorker::startDebuggerServer(const QString &packageDir, if (!m_debugServerProcess) { qCDebug(androidRunWorkerLog) << "Debugger process failed to start" << gdbServerErr; - if (errorStr) - *errorStr = Tr::tr("Failed to start debugger server."); - return false; + emit remoteProcessFinished(Tr::tr("Failed to start debugger server.")); + return; } qCDebug(androidRunWorkerLog) << "Debugger process started"; m_debugServerProcess->setObjectName("AndroidDebugServerProcess"); + // TODO: Repeats 3 times, refactor... const QString port = "tcp:" + m_localDebugServerPort.toString(); const QStringList removeForward{"forward", "--remove", port}; removeForwardPort(port); if (!runAdb({"forward", port, "localfilesystem:" + gdbServerSocket})) { - if (errorStr) - *errorStr = Tr::tr("Failed to forward C++ debugging ports."); - return false; + emit remoteProcessFinished(Tr::tr("Failed to forward C++ debugging ports.")); + return; } m_afterFinishAdbCommands.push_back(removeForward.join(' ')); } - return true; } void AndroidRunnerWorker::asyncStart() diff --git a/src/plugins/android/androidrunnerworker.h b/src/plugins/android/androidrunnerworker.h index 741b129fa92..713f50e9b93 100644 --- a/src/plugins/android/androidrunnerworker.h +++ b/src/plugins/android/androidrunnerworker.h @@ -62,7 +62,7 @@ private: void asyncStartHelper(); void startNativeDebugging(); - bool startDebuggerServer(const QString &packageDir, const QString &debugServerFile, QString *errorStr = nullptr); + void startDebuggerServer(const QString &packageDir, const QString &debugServerFile); bool deviceFileExists(const QString &filePath); bool packageFileExists(const QString& filePath); bool uploadDebugServer(const QString &debugServerFileName);