diff --git a/selfdrive/ui/qt/text.cc b/selfdrive/ui/qt/text.cc index 6cdd4b830e..011ed8189c 100644 --- a/selfdrive/ui/qt/text.cc +++ b/selfdrive/ui/qt/text.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -55,7 +56,26 @@ int main(int argc, char *argv[]) { update_btn->setText(QObject::tr("Update")); #ifdef __aarch64__ btn->setText(QObject::tr("Reboot")); - QFutureWatcher watcher; + + QProcess *command = new QProcess(); + QObject::connect(command, QOverload::of(&QProcess::finished), + [=](int exitCode, QProcess::ExitStatus exitStatus){ + btn->setEnabled(true); + update_btn->setEnabled(true); + update_btn->setText("Ready to Reboot"); + command->deleteLater(); // Delete QProcess after it finishes + }); + QObject::connect(command, &QProcess::readyReadStandardOutput, [=]() { + QByteArray result = command->readAllStandardOutput(); + label->setText(label->text() + "\n" + result); // appends the text to the QLabel + scroll->update(); + }); + QObject::connect(command, &QProcess::readyReadStandardError, [=]() { + QByteArray result = command->readAllStandardError(); + label->setText(label->text() + "\n" + result); // appends the text to the QLabel + scroll->update(); + }); + QObject::connect(btn, &QPushButton::clicked, [=]() { Hardware::reboot(); }); @@ -78,18 +98,8 @@ int main(int argc, char *argv[]) { } const std::string cmd = to_home_dir + "; " + remote_cmd + "; " + fetch_remote + "; " + reset_branch; - QFuture future = QtConcurrent::run([=]() { - std::string output = executeCommand(cmd.c_str()); - LOGW("CHECK OUTPUT PLS\n%s", output.c_str()); - QMetaObject::invokeMethod(label, "setText", Qt::QueuedConnection, - Q_ARG(QString, QString::fromStdString(output))); - }); - QObject::connect(&watcher, &QFutureWatcher::finished, [=]() { - btn->setEnabled(true); - update_btn->setEnabled(true); - update_btn->setText("Ready to Reboot"); - }); - watcher.setFuture(future); + QString c = QString::fromStdString(cmd); + command->start(c); }); #else update_btn->setEnabled(false);