From 490d9e0086284ccdf11cd774a7d009ebbb1d195a Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Sun, 15 Nov 2020 16:30:15 +0100 Subject: [PATCH] Check if onOpen/onClose reversed visibility change before forwarding it to the VR GUI Manager. --- apps/openmw/mwgui/windowbase.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/windowbase.cpp b/apps/openmw/mwgui/windowbase.cpp index bd859b86b..0c216b6de 100644 --- a/apps/openmw/mwgui/windowbase.cpp +++ b/apps/openmw/mwgui/windowbase.cpp @@ -62,11 +62,16 @@ void WindowBase::setVisible(bool visible) onClose(); #ifdef USE_OPENXR - auto* vrGUIManager = MWVR::Environment::get().getGUIManager(); - if (!vrGUIManager) - // May end up here before before rendering has been fully set up - return; - vrGUIManager->setVisible(this, visible); + // Check that onOpen/onClose didn't reverse the change before forwarding it + // to the VR GUI manager. + if (this->isVisible() == visible) + { + auto* vrGUIManager = MWVR::Environment::get().getGUIManager(); + if (!vrGUIManager) + // May end up here before before rendering has been fully set up + return; + vrGUIManager->setVisible(this, visible); + } #endif }