From 3749436cd5b2bce2790deaa5ddb3b33fa320ab46 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 23 Jan 2016 01:20:57 -0800 Subject: [PATCH] UI: Fix "invalid" audio devices in audio settings If a global audio device is disconnected or for whatever reason is no longer available when audio settings is opened, it will erroneously select index 0 of the combo box ("Disabled") by default because it can't find it in the combo box. This fixes that issue by making it insert an item in to the combo box specifying that the previously available audio device is no longer available, and properly preserving the user's settings. --- obs/data/locale/en-US.ini | 1 + obs/window-basic-settings.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/obs/data/locale/en-US.ini b/obs/data/locale/en-US.ini index 9c45f234..ac29a89b 100644 --- a/obs/data/locale/en-US.ini +++ b/obs/data/locale/en-US.ini @@ -420,6 +420,7 @@ Basic.Settings.Audio.EnablePushToMute="Enable Push-to-mute" Basic.Settings.Audio.PushToMuteDelay="Push-to-mute delay" Basic.Settings.Audio.EnablePushToTalk="Enable Push-to-talk" Basic.Settings.Audio.PushToTalkDelay="Push-to-talk delay" +Basic.Settings.Audio.UnknownAudioDevice="[Device not connected or not available]" # basic mode 'advanced' settings Basic.Settings.Advanced="Advanced" diff --git a/obs/window-basic-settings.cpp b/obs/window-basic-settings.cpp index 05b395c1..8f1a769b 100644 --- a/obs/window-basic-settings.cpp +++ b/obs/window-basic-settings.cpp @@ -1406,9 +1406,17 @@ void OBSBasicSettings::LoadListValues(QComboBox *widget, obs_property_t *prop, } if (deviceId) { - int idx = widget->findData(QVariant(QT_UTF8(deviceId))); - if (idx != -1) + QVariant var(QT_UTF8(deviceId)); + int idx = widget->findData(var); + if (idx != -1) { widget->setCurrentIndex(idx); + } else { + widget->insertItem(0, + QTStr("Basic.Settings.Audio." + "UnknownAudioDevice"), + var); + widget->setCurrentIndex(0); + } } if (settings) -- GitLab