History

Fallback display to last, then desktop

Zach Pomerantz committed 10 years ago

Commit 7bcef1d1 parent 34a77b41 file · +22 −6Browse files

Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Application.cpp+22−6
@@ -4886,6 +4886,7 @@ void Application::updateDisplayMode() { · 4885 unmodified lines
48864886 {
48874887 std::unique_lock<std::mutex> lock(_displayPluginLock);
48884888
4889+ auto oldDisplayPlugin = _displayPlugin;
48894890 if (_displayPlugin) {
48904891 _displayPlugin->deactivate();
48914892 }
@@ -4893,12 +4894,27 @@ void Application::updateDisplayMode() { · 1 unmodified line
48934894 // FIXME probably excessive and useless context switching
48944895 _offscreenContext->makeCurrent();
48954896
4896− // If the new plugin fails to activate, fallback to first item on the list
4897− if (!newDisplayPlugin->activate()) {
4898− qWarning() << "Failed to activate plugin: " << newDisplayPlugin->getName();
4899− newDisplayPlugin = displayPlugins.at(0);
4900− qWarning() << "Activating fallback plugin: " << newDisplayPlugin->getName();
4901− if (!newDisplayPlugin->activate()) {
4897+ bool active = newDisplayPlugin->activate();
4898+
4899+ if (!active) {
4900+ // If the new plugin fails to activate, fallback to last display
4901+ qWarning() << "Failed to activate display: " << newDisplayPlugin->getName();
4902+ newDisplayPlugin = oldDisplayPlugin;
4903+
4904+ if (newDisplayPlugin) {
4905+ qWarning() << "Falling back to last display: " << newDisplayPlugin->getName();
4906+ active = newDisplayPlugin->activate();
4907+ }
4908+
4909+ // If there is no last display, or
4910+ // If the last display fails to activate, fallback to desktop
4911+ if (!active) {
4912+ newDisplayPlugin = displayPlugins.at(0);
4913+ qWarning() << "Falling back to display: " << newDisplayPlugin->getName();
4914+ active = newDisplayPlugin->activate();
4915+ }
4916+
4917+ if (!active) {
49024918 qFatal("Failed to activate fallback plugin");
49034919 }
49044920 }