| 68 | } |
| 69 | |
| 70 | void WizObjectDownloaderHost::download(const WIZOBJECTDATA& data, DownloadType type, std::function<void(void)> callback) |
| 71 | { |
| 72 | Q_ASSERT(!data.strObjectGUID.isEmpty()); |
| 73 | // |
| 74 | { |
| 75 | QMutexLocker locker(&m_mutex); |
| 76 | if (m_mapObject.contains(data.strObjectGUID)) |
| 77 | { |
| 78 | qDebug() << "\n[downloader host] object already in the pool: " |
| 79 | << data.strDisplayName; |
| 80 | return; |
| 81 | } |
| 82 | // |
| 83 | m_mapObject[data.strObjectGUID] = data; |
| 84 | } |
| 85 | // |
| 86 | WizObjectDownloader* downloader = new WizObjectDownloader(data, type); |
| 87 | // |
| 88 | connect(downloader, SIGNAL(downloadDone(QString,bool)), this, SLOT(on_downloadDone(QString,bool))); |
| 89 | connect(downloader, SIGNAL(downloadProgress(QString,int,int)), this, SLOT(on_downloadProgress(QString,int,int))); |
| 90 | |
| 91 | if (!m_threadPool) |
| 92 | { |
| 93 | m_threadPool = WizCreateThreadPool(5); |
| 94 | } |
| 95 | |
| 96 | IWizRunable* action = WizCreateRunable([=](){ |
| 97 | downloader->run(); |
| 98 | downloader->deleteLater(); |
| 99 | if (callback) |
| 100 | { |
| 101 | callback(); |
| 102 | } |
| 103 | }); |
| 104 | m_threadPool->addTask(action); |
| 105 | } |
| 106 | |
| 107 | void WizObjectDownloaderHost::on_downloadDone(QString objectGUID, bool bSucceed) |
| 108 | { |
nothing calls this directly
no test coverage detected