From de45046445b722020c7ddc5b10348f01e903cdbb Mon Sep 17 00:00:00 2001 From: Aaron Colwell <300262+acolwell@users.noreply.github.com> Date: Sun, 24 Nov 2024 06:36:11 -0800 Subject: [PATCH] Fix null cache crashes. (#1002) --- Engine/AppManager.cpp | 12 +++++++++--- Engine/AppManagerPrivate.cpp | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Engine/AppManager.cpp b/Engine/AppManager.cpp index 586c5e303..8712eec00 100644 --- a/Engine/AppManager.cpp +++ b/Engine/AppManager.cpp @@ -457,9 +457,15 @@ AppManager::~AppManager() QThreadPool::globalInstance()->waitForDone(); ///Kill caches now because decreaseNCacheFilesOpened can be called - _imp->_nodeCache->waitForDeleterThread(); - _imp->_diskCache->waitForDeleterThread(); - _imp->_viewerCache->waitForDeleterThread(); + if (_imp->_nodeCache) { + _imp->_nodeCache->waitForDeleterThread(); + } + if (_imp->_diskCache) { + _imp->_diskCache->waitForDeleterThread(); + } + if (_imp->_viewerCache) { + _imp->_viewerCache->waitForDeleterThread(); + } _imp->_nodeCache.reset(); _imp->_viewerCache.reset(); _imp->_diskCache.reset(); diff --git a/Engine/AppManagerPrivate.cpp b/Engine/AppManagerPrivate.cpp index 55922950c..6f396a3cb 100644 --- a/Engine/AppManagerPrivate.cpp +++ b/Engine/AppManagerPrivate.cpp @@ -448,6 +448,10 @@ template void saveCache(Cache* cache) { + if (!cache) { + return; + } + std::string cacheRestoreFilePath = cache->getRestoreFilePath(); FStreamsSupport::ofstream ofile; FStreamsSupport::open(&ofile, cacheRestoreFilePath);