From d4e83a7461f1bcb10084b3411fdc13838798e999 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 12 Oct 2016 23:57:42 -0700 Subject: [PATCH] Don't crash on OpenVR activation when SteamVR isn't running --- plugins/openvr/src/OpenVrDisplayPlugin.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.cpp b/plugins/openvr/src/OpenVrDisplayPlugin.cpp index 50443ce73c..b9a491a8a2 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.cpp +++ b/plugins/openvr/src/OpenVrDisplayPlugin.cpp @@ -377,9 +377,6 @@ void OpenVrDisplayPlugin::init() { } bool OpenVrDisplayPlugin::internalActivate() { - _openVrDisplayActive = true; - _container->setIsOptionChecked(StandingHMDSensorMode, true); - if (!_system) { _system = acquireOpenVrSystem(); } @@ -388,6 +385,18 @@ bool OpenVrDisplayPlugin::internalActivate() { return false; } + // If OpenVR isn't running, then the compositor won't be accessible + // FIXME find a way to launch the compositor? + if (!vr::VRCompositor()) { + qWarning() << "Failed to acquire OpenVR compositor"; + releaseOpenVrSystem(); + _system = nullptr; + return false; + } + + _openVrDisplayActive = true; + _container->setIsOptionChecked(StandingHMDSensorMode, true); + _system->GetRecommendedRenderTargetSize(&_renderTargetSize.x, &_renderTargetSize.y); // Recommended render target size is per-eye, so double the X size for // left + right eyes