From ec0a166dd7f0dba8246e6d3c2debf5971a993e61 Mon Sep 17 00:00:00 2001
From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com>
Date: Fri, 21 Feb 2020 13:42:52 -0500
Subject: [PATCH] settingswidget: prevent crash when video device events happen
 with no account

Change-Id: I657d8b3793399b4a1f1819303c93684577743ada
---
 src/settingswidget.cpp | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp
index 06ee000..fef2fc4 100644
--- a/src/settingswidget.cpp
+++ b/src/settingswidget.cpp
@@ -1277,14 +1277,16 @@ SettingsWidget::populateVideoSettings()
         }
         ui->deviceBox->setCurrentIndex(deviceIndex);
         setFormatListForDevice(LRCInstance::avModel().getCurrentVideoCaptureDevice());
-
-        bool isSIP = LRCInstance::getCurrentAccountInfo().profileInfo.type == lrc::api::profile::Type::SIP;
-        auto photoBooth = isSIP ? ui->currentSIPAccountAvatar : ui->currentAccountAvatar;
-
-        if ( (photoBooth->isVisible() && LRCInstance::renderer()->isPreviewing()) ||
-             selectedMenu_ == SettingsMenu::Media) {
-            startPreviewing(false);
-        }
+        try
+        {
+            bool isSIP = LRCInstance::getCurrentAccountInfo().profileInfo.type == lrc::api::profile::Type::SIP;
+            auto photoBooth = isSIP ? ui->currentSIPAccountAvatar : ui->currentAccountAvatar;
+
+            if ((photoBooth->isVisible() && LRCInstance::renderer()->isPreviewing()) ||
+                selectedMenu_ == SettingsMenu::Media) {
+                startPreviewing(false);
+            }
+        } catch (...) {}
     }
 
     connect(ui->deviceBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
-- 
GitLab