Turn worker-object into a thread. Don't do a moveToThread() anymore.

This commit is contained in:
Gerhard Hoffmann 2023-11-07 09:07:08 +01:00
parent e65387aa60
commit e93058cc6b

View File

@ -158,31 +158,9 @@ Worker::Worker(int customerNr,
QDir::setCurrent(m_workingDirectory); QDir::setCurrent(m_workingDirectory);
m_apismVersion = getAPISMYoctoVersion(); m_apismVersion = getAPISMYoctoVersion();
this->moveToThread(&m_workerThread);
m_workerThread.start();
int cnt = 0;
while (!m_workerThread.isRunning()) {
if (++cnt > 5) {
Utils::printCriticalErrorMsg("starting worker thread FAILED");
return;
}
QThread::sleep(1);
}
} }
Worker::~Worker() { Worker::~Worker() {
int cnt = 0;
m_workerThread.quit();
while (!m_workerThread.isFinished()) {
if (!m_workerThread.wait(1000)) {
if (++cnt > 5) {
Utils::printCriticalErrorMsg("stopping worker thread FAILED");
return;
}
}
}
} }
void Worker::displayProgressInMainWindow(int progress) { void Worker::displayProgressInMainWindow(int progress) {
@ -207,7 +185,7 @@ void Worker::stopProgressLoop() {
} }
static std::once_flag once; static std::once_flag once;
void Worker::update() { void Worker::run() {
// user should not start the update process several times // user should not start the update process several times
std::call_once(once, &Worker::privateUpdate, this); std::call_once(once, &Worker::privateUpdate, this);
} }