Hi
I wrote simple Sqllite database app (automatic update to newer version). The only unusual thing in this app is that main thread is used for display progress bars and log output, and second thread exec update code.
Currently application works as expected but one thing does not work. After properly execution main thread is not informed about second thread finish!
My thread concept usage is as follow (example from Qt doc):
Qt Code:
  1. class Worker : public QObject
  2. {
  3. Q_OBJECT
  4.  
  5. public slots:
  6. void doWork(const QString &parameter) {
  7. QString result;
  8. /* ... here is the expensive or blocking operation ... */
  9. emit resultReady(result);
  10. }
  11.  
  12. signals:
  13. void resultReady(const QString &result);
  14. };
  15.  
  16. class Controller : public QObject
  17. {
  18. Q_OBJECT
  19. QThread workerThread;
  20. public:
  21. Controller() {
  22. Worker *worker = new Worker;
  23. worker->moveToThread(&workerThread);
  24. connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
  25. connect(this, &Controller::operate, worker, &Worker::doWork);
  26. connect(worker, &Worker::resultReady, this, &Controller::handleResults);
  27. workerThread.start();
  28. }
  29. ~Controller() {
  30. workerThread.quit();
  31. workerThread.wait();
  32. }
  33. public slots:
  34. void handleResults(const QString &);
  35. signals:
  36. void operate(const QString &);
  37. };
To copy to clipboard, switch view to plain text mode 

With exception that after workerThread.start(); I emit signal which call slot in the second thread (this is working task). After my operations I expect that QThread::finished() will be emitted by the second thread. But nothing happen like that...

So my questions are as follow:
1) do I something wrong?
2) Should I emit some custom signal from second thread to inform main thread about end of processing in the second thread?!?

thanks and best wishes
Szyk Cech