From a3b984f0a63a084402cbd84861c5c06e454e6d26 Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Mon, 31 Dec 2018 12:31:24 -0500
Subject: [PATCH] fix crash on app start

Change-Id: I1e2c14fe4b7ae0f133fe6a23a12ae301ab6b5408
---
 videooverlay.cpp | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/videooverlay.cpp b/videooverlay.cpp
index 545ab28..12bcfd0 100644
--- a/videooverlay.cpp
+++ b/videooverlay.cpp
@@ -46,8 +46,28 @@ VideoOverlay::VideoOverlay(QWidget* parent) :
 
     ui->onHoldLabel->setVisible(false);
 
-    connect(LRCInstance::getCurrentCallModel(), &lrc::api::NewCallModel::callStarted,
-        [this](const std::string& tempCallId) { callId = tempCallId; });
+    auto accountList = LRCInstance::accountModel().getAccountList();
+    if (!accountList.size()) {
+        QMetaObject::Connection* const connection = new QMetaObject::Connection;
+        connect(&LRCInstance::accountModel(),
+            &lrc::api::NewAccountModel::accountAdded,
+            [this, connection](const std::string& accountId) {
+                Q_UNUSED(accountId);
+                connect(LRCInstance::getCurrentCallModel(), &lrc::api::NewCallModel::callStarted,
+                    [this](const std::string& tempCallId) {
+                        callId = tempCallId;
+                    });
+                QObject::disconnect(*connection);
+                if (connection) {
+                    delete connection;
+                }
+            });
+    } else {
+        connect(LRCInstance::getCurrentCallModel(), &lrc::api::NewCallModel::callStarted,
+            [this](const std::string& tempCallId) {
+                callId = tempCallId;
+            });
+    }
 
     connect(oneSecondTimer_, &QTimer::timeout, this, &VideoOverlay::setTime);
     oneSecondTimer_->start(1000);
-- 
GitLab