From ba71728979481187e0dc619f06c328c9ca3b3106 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Sat, 9 Sep 2023 14:30:53 +0200 Subject: [PATCH] Move the dc-plugin (and the update-object) into the gui-thread instead of the worker thread, so the worker-thread cannot block itself when inside a slot and therefore not able to react to qt-signals. --- main.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 16db53b..34d8085 100644 --- a/main.cpp +++ b/main.cpp @@ -32,6 +32,12 @@ #include #include +#include + +#if defined (Q_OS_UNIX) || defined (Q_OS_LINUX) +#include +#include +#endif #ifdef PTU5 #define SERIAL_PORT "ttymxc2" @@ -58,6 +64,24 @@ int main(int argc, char *argv[]) { setDebugLevel(LOG_NOTICE); } +//#if defined (Q_OS_UNIX) || defined (Q_OS_LINUX) +//#ifdef _POSIX_THREAD_PROCESS_SHARED +// errno = 0; +// int res = 0; +// if ((res = sysconf(_SC_THREAD_PROCESS_SHARED)) < 0) { +// if (errno != 0) { +// qCritical() << "_POSIX_THREAD_PROCESS_SHARED NOT SUPPORTED" +// << strerror(errno); +// exit(-1); +// } +// } else { +// if (res == _POSIX_THREAD_PROCESS_SHARED) { +// Utils::printInfoMsg("_POSIX_THREAD_PROCESS_SHARED SUPPORTED"); +// } +// } +//#endif +//#endif + QCommandLineParser parser; parser.setApplicationDescription("Download tool for downloading device controller firmware, printer json-files and executing opkg-commands."); parser.addHelpOption(); @@ -116,7 +140,8 @@ int main(int argc, char *argv[]) { #endif hwinf *hw = Update::loadDCPlugin(QDir(plugInDir), plugInName); - hw->dc_autoRequest(false); + hw->dc_autoRequest(true); + // hw->dc_openSerial(5, "115200", "ttymxc2", 1); int machineNr = Utils::read1stLineOfFile("/etc/machine_nr"); int customerNr = Utils::read1stLineOfFile("/etc/cust_nr"); @@ -135,7 +160,23 @@ int main(int argc, char *argv[]) { workingDir, dryRun); - MainWindow mw(hw, &worker); + QString const customerNrStr( + QString("customer_") + QString::number(customerNr).rightJustified(3, '0')); + + QScopedPointer update( + new Update(hw, + &worker, + QDir::cleanPath(workingDir + QDir::separator() + customerNrStr), + customerNrStr, + branchName, + plugInName, + workingDir, + dryRun, + nullptr, + SERIAL_PORT, + "115200")); + + MainWindow mw(hw, &worker, update.get()); worker.setMainWindow(&mw); mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);