diff --git a/src/accountadapter.cpp b/src/accountadapter.cpp index e39c39deccdd267d135eb7c055d54d3c3af2de4e..f81675974795cc25e31148a4ff0e49e20effca4d 100644 --- a/src/accountadapter.cpp +++ b/src/accountadapter.cpp @@ -48,10 +48,6 @@ AccountAdapter::AccountAdapter(AppSettingsManager* settingsManager, &AccountAdapter::accountStatusChanged); } -void -AccountAdapter::safeInit() -{} - NewAccountModel* AccountAdapter::getModel() { diff --git a/src/accountadapter.h b/src/accountadapter.h index 313b2ad0de9a94c00911f101039a7828298ddf34..c41dfc12ced0be55dbec3b56fab4b580052dccc8 100644 --- a/src/accountadapter.h +++ b/src/accountadapter.h @@ -50,7 +50,7 @@ public: QObject* parent = nullptr); ~AccountAdapter() = default; - void safeInit() override; + void safeInit() override {} // Change to account corresponding to combox box index. Q_INVOKABLE void changeAccount(int row); diff --git a/src/contactadapter.cpp b/src/contactadapter.cpp index 621cd21d8c8cbd43ce0f1e6e7e3871f55bd0cf8b..96227a7375ac2e61fc8fcb72b61aa5c242ed774c 100644 --- a/src/contactadapter.cpp +++ b/src/contactadapter.cpp @@ -26,18 +26,10 @@ ContactAdapter::ContactAdapter(LRCInstance* instance, QObject* parent) : QmlAdapterBase(instance, parent) { selectableProxyModel_.reset(new SelectableProxyModel(this)); -} - -void -ContactAdapter::safeInit() -{ - connect(lrcInstance_, &LRCInstance::currentAccountIdChanged, [this] { - connect(lrcInstance_->getCurrentContactModel(), - &ContactModel::bannedStatusChanged, - this, - &ContactAdapter::bannedStatusChanged, - Qt::UniqueConnection); - }); + if (lrcInstance_) { + connectSignals(); + connect(lrcInstance_, &LRCInstance::currentAccountIdChanged, [this] { connectSignals(); }); + } } QVariant @@ -194,3 +186,13 @@ ContactAdapter::contactSelected(int index) } } } + +void +ContactAdapter::connectSignals() +{ + connect(lrcInstance_->getCurrentContactModel(), + &ContactModel::bannedStatusChanged, + this, + &ContactAdapter::bannedStatusChanged, + Qt::UniqueConnection); +} diff --git a/src/contactadapter.h b/src/contactadapter.h index fa3e645d2a4dc8e75a08bb81bb27e8b6aac5f089..a4c15a23cfc48b80cf23c2c0b8d57902c8139695 100644 --- a/src/contactadapter.h +++ b/src/contactadapter.h @@ -86,12 +86,14 @@ public: using Role = ConversationList::Role; - void safeInit() override; + void safeInit() override {} Q_INVOKABLE QVariant getContactSelectableModel(int type); Q_INVOKABLE void setSearchFilter(const QString& filter); Q_INVOKABLE void contactSelected(int index); + void connectSignals(); + Q_SIGNALS: void bannedStatusChanged(const QString& uri, bool banned);