Fix nullptr crash in handleVSyncChanged

master
Rye Mutt 2024-07-22 10:59:35 -04:00 committed by Andrey Kleshchev
parent 9e379a5578
commit 04fdc4f2c0
1 changed files with 8 additions and 5 deletions

View File

@ -263,12 +263,15 @@ static bool handleAnisotropicChanged(const LLSD& newvalue)
static bool handleVSyncChanged(const LLSD& newvalue)
{
LLPerfStats::tunables.vsyncEnabled = newvalue.asBoolean();
gViewerWindow->getWindow()->toggleVSync(newvalue.asBoolean());
if (newvalue.asBoolean())
if (gViewerWindow && gViewerWindow->getWindow())
{
U32 current_target = gSavedSettings.getU32("TargetFPS");
gSavedSettings.setU32("TargetFPS", std::min((U32)gViewerWindow->getWindow()->getRefreshRate(), current_target));
gViewerWindow->getWindow()->toggleVSync(newvalue.asBoolean());
if (newvalue.asBoolean())
{
U32 current_target = gSavedSettings.getU32("TargetFPS");
gSavedSettings.setU32("TargetFPS", std::min((U32)gViewerWindow->getWindow()->getRefreshRate(), current_target));
}
}
return true;