From 7bcef1d3194cbfd7e7dc995b067df3d2db7a1df7 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Mon, 28 Mar 2016 12:54:38 -0700 Subject: [PATCH] Fallback display to last, then desktop --- interface/src/Application.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7f2d1d2af5..7eb19557e5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4886,6 +4886,7 @@ void Application::updateDisplayMode() { { std::unique_lock lock(_displayPluginLock); + auto oldDisplayPlugin = _displayPlugin; if (_displayPlugin) { _displayPlugin->deactivate(); } @@ -4893,12 +4894,27 @@ void Application::updateDisplayMode() { // FIXME probably excessive and useless context switching _offscreenContext->makeCurrent(); - // If the new plugin fails to activate, fallback to first item on the list - if (!newDisplayPlugin->activate()) { - qWarning() << "Failed to activate plugin: " << newDisplayPlugin->getName(); - newDisplayPlugin = displayPlugins.at(0); - qWarning() << "Activating fallback plugin: " << newDisplayPlugin->getName(); - if (!newDisplayPlugin->activate()) { + bool active = newDisplayPlugin->activate(); + + if (!active) { + // If the new plugin fails to activate, fallback to last display + qWarning() << "Failed to activate display: " << newDisplayPlugin->getName(); + newDisplayPlugin = oldDisplayPlugin; + + if (newDisplayPlugin) { + qWarning() << "Falling back to last display: " << newDisplayPlugin->getName(); + active = newDisplayPlugin->activate(); + } + + // If there is no last display, or + // If the last display fails to activate, fallback to desktop + if (!active) { + newDisplayPlugin = displayPlugins.at(0); + qWarning() << "Falling back to display: " << newDisplayPlugin->getName(); + active = newDisplayPlugin->activate(); + } + + if (!active) { qFatal("Failed to activate fallback plugin"); } }