| 179 | /// -------------------------- VideoCache::loadingThread -------------------- |
| 180 | |
| 181 | class VideoCache::loadingThread : public QThread |
| 182 | { |
| 183 | Q_OBJECT |
| 184 | public: |
| 185 | loadingThread(QObject *parent) : QThread(parent) |
| 186 | { |
| 187 | // Create a new worker and move it to this thread |
| 188 | threadWorker.reset(new loadingWorker(nullptr)); |
| 189 | threadWorker->moveToThread(this); |
| 190 | quitting = false; |
| 191 | } |
| 192 | void quitWhenDone() |
| 193 | { |
| 194 | quitting = true; |
| 195 | if (threadWorker->isWorking()) |
| 196 | { |
| 197 | // We must wait until the worker is done. |
| 198 | DEBUG_CACHING("loadingThread::quitWhenDone waiting for worker to finish..."); |
| 199 | connect(worker(), &loadingWorker::loadingFinished, this, [=] { |
| 200 | DEBUG_CACHING("loadingThread::quitWhenDone worker done -> quit"); |
| 201 | quit(); |
| 202 | }); |
| 203 | } |
| 204 | else |
| 205 | { |
| 206 | DEBUG_CACHING("loadingThread::quitWhenDone quit now"); |
| 207 | quit(); |
| 208 | } |
| 209 | } |
| 210 | loadingWorker *worker() { return threadWorker.data(); } |
| 211 | bool isQuitting() { return quitting; } |
| 212 | |
| 213 | private: |
| 214 | QScopedPointer<loadingWorker> threadWorker; |
| 215 | bool quitting; // Are er quitting the job? If yes, do not push new jobs to it. |
| 216 | }; |
| 217 | |
| 218 | /// ---------------------------------- VideoCache ------------------------------ |
| 219 |
nothing calls this directly
no test coverage detected