| 430 | } |
| 431 | |
| 432 | AppManager::~AppManager() |
| 433 | { |
| 434 | #ifdef NATRON_USE_BREAKPAD |
| 435 | if (_imp->breakpadAliveThread) { |
| 436 | _imp->breakpadAliveThread->quitThread(); |
| 437 | } |
| 438 | #endif |
| 439 | |
| 440 | bool appsEmpty; |
| 441 | { |
| 442 | QMutexLocker k(&_imp->_appInstancesMutex); |
| 443 | appsEmpty = _imp->_appInstances.empty(); |
| 444 | } |
| 445 | while (!appsEmpty) { |
| 446 | AppInstancePtr front; |
| 447 | { |
| 448 | QMutexLocker k(&_imp->_appInstancesMutex); |
| 449 | front = _imp->_appInstances.front(); |
| 450 | } |
| 451 | if (front) { |
| 452 | front->quitNow(); |
| 453 | } |
| 454 | { |
| 455 | QMutexLocker k(&_imp->_appInstancesMutex); |
| 456 | appsEmpty = _imp->_appInstances.empty(); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | for (PluginsMap::iterator it = _imp->_plugins.begin(); it != _imp->_plugins.end(); ++it) { |
| 461 | for (PluginVersionsOrdered::reverse_iterator itver = it->second.rbegin(); itver != it->second.rend(); ++itver) { |
| 462 | delete *itver; |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | _imp->_backgroundIPC.reset(); |
| 467 | |
| 468 | try { |
| 469 | _imp->saveCaches(); |
| 470 | } catch (std::runtime_error&) { |
| 471 | // ignore errors |
| 472 | } |
| 473 | |
| 474 | ///Caches may have launched some threads to delete images, wait for them to be done |
| 475 | QThreadPool::globalInstance()->waitForDone(); |
| 476 | |
| 477 | ///Kill caches now because decreaseNCacheFilesOpened can be called |
| 478 | _imp->_nodeCache->waitForDeleterThread(); |
| 479 | _imp->_diskCache->waitForDeleterThread(); |
| 480 | _imp->_viewerCache->waitForDeleterThread(); |
| 481 | _imp->_nodeCache.reset(); |
| 482 | _imp->_viewerCache.reset(); |
| 483 | _imp->_diskCache.reset(); |
| 484 | |
| 485 | tearDownPython(); |
| 486 | _imp->tearDownGL(); |
| 487 | |
| 488 | _instance = 0; |
| 489 |
nothing calls this directly
no test coverage detected