From 3fc824d770267e870d7151ef6282b3bc8e1a5e12 Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Wed, 2 Jan 2019 15:20:21 -0500
Subject: [PATCH] wizard: update account information after creating first
 account

Change-Id: I4f952f145184f74b5d744623bb6e2dd182e6ceae
---
 callwidget.cpp      |  9 +++++++++
 newwizardwidget.cpp | 10 +++++-----
 videooverlay.cpp    |  2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/callwidget.cpp b/callwidget.cpp
index 57a99d9..8cac5a0 100644
--- a/callwidget.cpp
+++ b/callwidget.cpp
@@ -235,6 +235,15 @@ CallWidget::navigated(bool to)
     if (to) {
         updateSmartList();
         connectConversationModel();
+        try {
+            auto accountList = LRCInstance::accountModel().getAccountList();
+            if (accountList.size() == 1) {
+                auto index = Utils::indexInVector(accountList, LRCInstance::getCurrAccId());
+                if (index != -1) {
+                    slotAccountChanged(index);
+                }
+            }
+        } catch (...) {}
         ui->currentAccountComboBox->updateComboBoxDisplay();
     } else {
         QObject::disconnect(smartlistSelectionConnection_);
diff --git a/newwizardwidget.cpp b/newwizardwidget.cpp
index e1c74dd..6acce35 100644
--- a/newwizardwidget.cpp
+++ b/newwizardwidget.cpp
@@ -413,11 +413,6 @@ NewWizardWidget::createRingAccount(const QString &displayName,
             auto confProps = LRCInstance::accountModel().getAccountConfig(accountId);
             confProps.Ringtone.ringtonePath = Utils::GetRingtonePath().toStdString();
             LRCInstance::accountModel().setAccountConfig(accountId, confProps);
-            LRCInstance::editableAccountModel()->registerName(
-                LRCInstance::getCurrAccId(),
-                "",
-                registeredName_.toStdString()
-            );
             connect(LRCInstance::editableAccountModel(),
                 &lrc::api::NewAccountModel::nameRegistrationEnded,
                 [this] {
@@ -425,6 +420,11 @@ NewWizardWidget::createRingAccount(const QString &displayName,
                     LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), accountProperties);
                     emit NavigationRequested(ScreenEnum::CallScreen);
                 });
+            LRCInstance::editableAccountModel()->registerName(
+                LRCInstance::getCurrAccId(),
+                "",
+                registeredName_.toStdString()
+            );
             if (ui->setAvatarWidget->hasAvatar()) {
                 LRCInstance::setCurrAccAvatar(ui->setAvatarWidget->getAvatarPixmap());
             }
diff --git a/videooverlay.cpp b/videooverlay.cpp
index 97a6e82..1a133b3 100644
--- a/videooverlay.cpp
+++ b/videooverlay.cpp
@@ -57,8 +57,8 @@ VideoOverlay::VideoOverlay(QWidget* parent) :
                     [this](const std::string& tempCallId) {
                         callId = tempCallId;
                     });
-                QObject::disconnect(*connection);
                 if (connection) {
+                    QObject::disconnect(*connection);
                     delete connection;
                 }
             });
-- 
GitLab