| 423 | } |
| 424 | |
| 425 | void VideoCache::interactiveLoaderFinished() |
| 426 | { |
| 427 | // Get the thread that caused this call |
| 428 | QObject * sender = QObject::sender(); |
| 429 | loadingWorker *worker = dynamic_cast<loadingWorker *>(sender); |
| 430 | int threadID = (interactiveThread[0]->worker() == worker) ? 0 : 1; |
| 431 | assert(worker == interactiveThread[0]->worker() || worker == interactiveThread[1]->worker()); |
| 432 | |
| 433 | // Check the list of items that are scheduled for deletion. Because a loading thread finished, |
| 434 | // maybe now we can delete the item(s). |
| 435 | for (auto it = itemsToDelete.begin(); it != itemsToDelete.end();) |
| 436 | { |
| 437 | // Is the item still being cached? |
| 438 | bool itemCaching = false; |
| 439 | for (loadingThread *t : cachingThreadList) |
| 440 | if (t->worker()->getCacheItem() == *it) |
| 441 | { |
| 442 | itemCaching = true; |
| 443 | break; |
| 444 | } |
| 445 | // Is the item still being loaded? |
| 446 | bool loadingItem = (interactiveThread[0]->worker()->getCacheItem() == *it || |
| 447 | interactiveThread[1]->worker()->getCacheItem() == *it); |
| 448 | |
| 449 | if (!itemCaching && !loadingItem) |
| 450 | { |
| 451 | // Remove the item from the loading queue (if in there) |
| 452 | if (interactiveItemQueued[threadID] == (*it)) |
| 453 | { |
| 454 | interactiveItemQueued[threadID] = nullptr; |
| 455 | interactiveItemQueued_Idx[threadID] = -1; |
| 456 | } |
| 457 | // Delete the item and remove it from the itemsToDelete list |
| 458 | DEBUG_CACHING("VideoCache::interactiveLoaderFinished delete item now %s", |
| 459 | (*it)->getName().toLatin1().data()); |
| 460 | (*it)->deleteLater(); |
| 461 | it = itemsToDelete.erase(it); |
| 462 | } |
| 463 | else |
| 464 | ++it; |
| 465 | } |
| 466 | |
| 467 | // The worker finished. Is there another loading request in the queue? |
| 468 | if (interactiveItemQueued[threadID] != nullptr && interactiveItemQueued_Idx[threadID] >= 0) |
| 469 | { |
| 470 | // Let the interactive worker work on the queued request. |
| 471 | bool loadRawData = splitView->showRawData() && !playback->playing(); |
| 472 | interactiveThread[threadID]->worker()->setJob(interactiveItemQueued[threadID], |
| 473 | interactiveItemQueued_Idx[threadID]); |
| 474 | interactiveThread[threadID]->worker()->setWorking(true); |
| 475 | interactiveThread[threadID]->worker()->processLoadingJob(playback->playing(), loadRawData); |
| 476 | DEBUG_CACHING_DETAIL("VideoCache::interactiveLoaderFinished %d started - slot %d", |
| 477 | interactiveItemQueued_Idx[threadID], |
| 478 | threadID); |
| 479 | |
| 480 | // Clear the queue slot |
| 481 | interactiveItemQueued[threadID] = nullptr; |
| 482 | interactiveItemQueued_Idx[threadID] = -1; |
nothing calls this directly
no test coverage detected