From 6d4c247de7880c588f7ba2b034f92bb1454f2a40 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Mon, 22 May 2023 16:04:50 +0200 Subject: [PATCH] Using update.h/.cpp and thread pool --- main.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index 4da5633..8941d18 100644 --- a/main.cpp +++ b/main.cpp @@ -16,7 +16,7 @@ #include #include -#include "utils.h" +#include "update.h" #ifdef PTU5 #define SERIAL_PORT "ttymxc2" @@ -25,11 +25,13 @@ #endif class Work : public QRunnable { - Utils m_utils; + QString m_update_ctrl_file; public: - explicit Work(QString update_ctrl_file) : m_utils(update_ctrl_file) {} + explicit Work(QString update_ctrl_file) + : m_update_ctrl_file(update_ctrl_file) {} void run() { - m_utils.doUpdate(); + Update m_update(m_update_ctrl_file); + m_update.doUpdate(); } }; @@ -47,11 +49,14 @@ int main(int argc, char *argv[]) { if (argc == 2) { update_ctrl_file = argv[1]; } - qCritical() << "Using" << update_ctrl_file << "as update logfile"; + qInfo() << "Using" << update_ctrl_file << "as update logfile"; Work work(update_ctrl_file); work.setAutoDelete(false); QThreadPool *threadPool = QThreadPool::globalInstance(); threadPool->start(&work); - return threadPool->waitForDone(); + if (!threadPool->waitForDone()) { + return -1; + } + return 0; }