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.
This commit is contained in:
		
							
								
								
									
										45
									
								
								main.cpp
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								main.cpp
									
									
									
									
									
								
							@@ -32,6 +32,12 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <QThread>
 | 
					#include <QThread>
 | 
				
			||||||
#include <QtWidgets>
 | 
					#include <QtWidgets>
 | 
				
			||||||
 | 
					#include <QScopedPointer>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined (Q_OS_UNIX) || defined (Q_OS_LINUX)
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef PTU5
 | 
					#ifdef PTU5
 | 
				
			||||||
#define SERIAL_PORT "ttymxc2"
 | 
					#define SERIAL_PORT "ttymxc2"
 | 
				
			||||||
@@ -58,6 +64,24 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
        setDebugLevel(LOG_NOTICE);
 | 
					        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;
 | 
					    QCommandLineParser parser;
 | 
				
			||||||
    parser.setApplicationDescription("Download tool for downloading device controller firmware, printer json-files and executing opkg-commands.");
 | 
					    parser.setApplicationDescription("Download tool for downloading device controller firmware, printer json-files and executing opkg-commands.");
 | 
				
			||||||
    parser.addHelpOption();
 | 
					    parser.addHelpOption();
 | 
				
			||||||
@@ -116,7 +140,8 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    hwinf *hw = Update::loadDCPlugin(QDir(plugInDir), plugInName);
 | 
					    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 machineNr = Utils::read1stLineOfFile("/etc/machine_nr");
 | 
				
			||||||
    int customerNr = Utils::read1stLineOfFile("/etc/cust_nr");
 | 
					    int customerNr = Utils::read1stLineOfFile("/etc/cust_nr");
 | 
				
			||||||
@@ -135,7 +160,23 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
                  workingDir,
 | 
					                  workingDir,
 | 
				
			||||||
                  dryRun);
 | 
					                  dryRun);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    MainWindow mw(hw, &worker);
 | 
					    QString const customerNrStr(
 | 
				
			||||||
 | 
					        QString("customer_") + QString::number(customerNr).rightJustified(3, '0'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QScopedPointer<Update> 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);
 | 
					    worker.setMainWindow(&mw);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
 | 
					    mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user