void FileNetworkTask::startFileServerTask(const QString& link) { createFileServerTask(link); connect(fileserver_task_, SIGNAL(progressUpdate(qint64, qint64)), this, SLOT(onFileServerTaskProgressUpdate(qint64, qint64))); connect(fileserver_task_, SIGNAL(nameUpdate(QString)), this, SLOT(onFileServerTaskNameUpdate(QString))); connect(fileserver_task_, SIGNAL(finished(bool)), this, SLOT(onFileServerTaskFinished(bool))); connect(fileserver_task_, SIGNAL(retried(int)), this, SIGNAL(retried(int))); if (!worker_thread_) { worker_thread_ = new QThread; worker_thread_->start(); } if (type() == Download) { // From now on the this task would run in the worker thread fileserver_task_->moveToThread(worker_thread_); QMetaObject::invokeMethod(fileserver_task_, "start"); } else { // ReliablePostFileTask is a bit complicated and it would manage the // thread-affinity itself. fileserver_task_->start(); } }
void FileNetworkTask::startFileServerTask(const QString& link) { createFileServerTask(link); connect(fileserver_task_, SIGNAL(progressUpdate(qint64, qint64)), this, SLOT(onFileServerTaskProgressUpdate(qint64, qint64))); connect(fileserver_task_, SIGNAL(finished(bool)), this, SLOT(onFileServerTaskFinished(bool))); if (!worker_thread_) { worker_thread_ = new QThread; worker_thread_->start(); } // From now on the transfer task would run in the worker thread fileserver_task_->moveToThread(worker_thread_); QMetaObject::invokeMethod(fileserver_task_, "start"); }