diff --git a/src/plugins/boot2qt/deviceapplicationobserver.cpp b/src/plugins/boot2qt/deviceapplicationobserver.cpp index 2faf717b5c2..1cbda35cf0d 100644 --- a/src/plugins/boot2qt/deviceapplicationobserver.cpp +++ b/src/plugins/boot2qt/deviceapplicationobserver.cpp @@ -51,29 +51,18 @@ DeviceApplicationObserver::DeviceApplicationObserver(QObject *parent) } void DeviceApplicationObserver::start(const IDevice::ConstPtr &device, - const QList &commands) + const Command &command) { QTC_ASSERT(device, return); m_device = device; - m_commandsToRun = commands; - runNext(); -} + m_command = command; -void DeviceApplicationObserver::runNext() -{ - if (m_commandsToRun.isEmpty()) { - showMessage(tr("Commands on device '%1' finished successfully.") - .arg(m_device->displayName())); - deleteLater(); - return; - } - const Command c = m_commandsToRun.takeFirst(); m_stdout.clear(); m_stderr.clear(); Runnable r; - r.executable = c.binary; - r.commandLineArguments = Utils::QtcProcess::joinArgs(c.arguments); + r.executable = m_command.binary; + r.commandLineArguments = Utils::QtcProcess::joinArgs(m_command.arguments); m_appRunner->start(r, m_device); showMessage(tr("Starting command '%1 %2' on device '%3'.") .arg(r.executable, r.commandLineArguments, m_device->displayName())); @@ -113,10 +102,11 @@ void DeviceApplicationObserver::handleFinished(bool success) showMessage(tr("stdout was: '%1'").arg(m_stdout)); if (!m_stderr.isEmpty()) showMessage(tr("stderr was: '%1'").arg(m_stderr)); - deleteLater(); - return; + } else { + showMessage(tr("Commands on device '%1' finished successfully.") + .arg(m_device->displayName())); } - runNext(); + deleteLater(); } } // namespace Internal diff --git a/src/plugins/boot2qt/deviceapplicationobserver.h b/src/plugins/boot2qt/deviceapplicationobserver.h index f82abbb3b49..f67a6989787 100644 --- a/src/plugins/boot2qt/deviceapplicationobserver.h +++ b/src/plugins/boot2qt/deviceapplicationobserver.h @@ -36,9 +36,6 @@ namespace Internal { class Command { public: - Command(const QString &bin, const QStringList &args = QStringList()) - : binary(bin), arguments(args) {} - QString binary; QStringList arguments; }; @@ -50,18 +47,17 @@ public: explicit DeviceApplicationObserver(QObject *parent = 0); // Once all commands have finished, this object will delete itself. - void start(const ProjectExplorer::IDevice::ConstPtr &device, const QList &commands); + void start(const ProjectExplorer::IDevice::ConstPtr &device, const Command &command); private: void handleStdout(const QString &data); void handleStderr(const QString &data); void handleError(const QString &message); void handleFinished(bool success); - void runNext(); QString m_stdout; QString m_stderr; - QList m_commandsToRun; + Command m_command; ProjectExplorer::ApplicationLauncher * const m_appRunner; ProjectExplorer::IDevice::ConstPtr m_device; QString m_error; diff --git a/src/plugins/boot2qt/qdbdevice.cpp b/src/plugins/boot2qt/qdbdevice.cpp index 9fd55955936..1185e04e5d3 100644 --- a/src/plugins/boot2qt/qdbdevice.cpp +++ b/src/plugins/boot2qt/qdbdevice.cpp @@ -45,13 +45,13 @@ namespace Internal { QdbDevice::QdbDevice() { addDeviceAction({tr("Reboot Device"), [](const IDevice::Ptr &device, QWidget *) { - QList commands{Command("reboot")}; - (new DeviceApplicationObserver)->start(device, commands); + Command cmd{"reboot", {}}; + (new DeviceApplicationObserver)->start(device, cmd); }}); addDeviceAction({tr("Restore Default App"), [](const IDevice::Ptr &device, QWidget *) { - QList commands{Command(appControllerFilePath(), QStringList{"--remove-default"})}; - (new DeviceApplicationObserver)->start(device, commands); + Command cmd{appControllerFilePath(), {"--remove-default"}}; + (new DeviceApplicationObserver)->start(device, cmd); }}); }