From a067d3afd4e5921c04035b4b0545ddfbd20e0465 Mon Sep 17 00:00:00 2001 From: cdozdila Date: Tue, 29 Apr 2025 22:36:43 +0300 Subject: [PATCH] Prevent crashes when OptiFG is not active --- OptiScaler/hooks/wrapped_swapchain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OptiScaler/hooks/wrapped_swapchain.cpp b/OptiScaler/hooks/wrapped_swapchain.cpp index e0cd237b..6dba1b78 100644 --- a/OptiScaler/hooks/wrapped_swapchain.cpp +++ b/OptiScaler/hooks/wrapped_swapchain.cpp @@ -234,7 +234,7 @@ HRESULT STDMETHODCALLTYPE WrappedIDXGISwapChain4::SetFullscreenState(BOOL Fullsc if (Config::Instance()->FGUseMutexForSwaphain.value_or_default()) { - if (State::Instance().currentFG->Mutex.getOwner() != 3) + if (State::Instance().currentFG != nullptr && State::Instance().currentFG->Mutex.getOwner() != 3) { LOG_TRACE("Waiting ffxMutex 3, current: {}", State::Instance().currentFG->Mutex.getOwner()); State::Instance().currentFG->Mutex.lock(3); @@ -320,7 +320,7 @@ HRESULT STDMETHODCALLTYPE WrappedIDXGISwapChain4::ResizeBuffers(UINT BufferCount OwnedLockGuard lock(_localMutex, 1); #endif - if (Config::Instance()->FGUseMutexForSwaphain.value_or_default()) + if (State::Instance().currentFG != nullptr && Config::Instance()->FGUseMutexForSwaphain.value_or_default()) { LOG_TRACE("Waiting ffxMutex 3, current: {}", State::Instance().currentFG->Mutex.getOwner()); State::Instance().currentFG->Mutex.lock(3); @@ -425,7 +425,7 @@ HRESULT STDMETHODCALLTYPE WrappedIDXGISwapChain4::ResizeBuffers(UINT BufferCount LOG_DEBUG("result: {0:X}", (UINT)result); - if (Config::Instance()->FGUseMutexForSwaphain.value_or_default()) + if (State::Instance().currentFG != nullptr && Config::Instance()->FGUseMutexForSwaphain.value_or_default()) { LOG_TRACE("Releasing ffxMutex: {}", State::Instance().currentFG->Mutex.getOwner()); State::Instance().currentFG->Mutex.unlockThis(3);