From 70c520e867a19937854e5695d786857b7e7b0e20 Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Fri, 4 Jun 2021 14:15:19 -0400 Subject: [PATCH] pendingConferenceesListModel: avoid invalid connections Change-Id: I9d073cb5203a887fd5e39ced258b19e0196d069b --- src/calloverlaymodel.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/calloverlaymodel.cpp b/src/calloverlaymodel.cpp index b0160ee2c..ca15db184 100644 --- a/src/calloverlaymodel.cpp +++ b/src/calloverlaymodel.cpp @@ -125,17 +125,18 @@ PendingConferenceesListModel::connectSignals() disconnect(beginRemovePendingConferencesRows_); disconnect(endRemovePendingConferencesRows_); + auto currentCallModel = lrcInstance_->getCurrentCallModel(); + if (!currentCallModel) + return; + using namespace PendingConferences; - callsStatusChanged_ = connect(lrcInstance_->getCurrentCallModel(), - &NewCallModel::callStatusChanged, - [this](const QString&, int) { - Q_EMIT dataChanged(index(0, 0), - index(rowCount() - 1), - {Role::CallStatus}); - }); + callsStatusChanged_ + = connect(currentCallModel, &NewCallModel::callStatusChanged, [this](const QString&, int) { + Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1), {Role::CallStatus}); + }); beginInsertPendingConferencesRows_ = connect( - lrcInstance_->getCurrentCallModel(), + currentCallModel, &NewCallModel::beginInsertPendingConferenceesRows, this, [this](int position, int rows) { @@ -144,14 +145,14 @@ PendingConferenceesListModel::connectSignals() Qt::DirectConnection); endInsertPendingConferencesRows_ = connect( - lrcInstance_->getCurrentCallModel(), + currentCallModel, &NewCallModel::endInsertPendingConferenceesRows, this, [this]() { endInsertRows(); }, Qt::DirectConnection); beginRemovePendingConferencesRows_ = connect( - lrcInstance_->getCurrentCallModel(), + currentCallModel, &NewCallModel::beginRemovePendingConferenceesRows, this, [this](int position, int rows) { @@ -160,7 +161,7 @@ PendingConferenceesListModel::connectSignals() Qt::DirectConnection); endRemovePendingConferencesRows_ = connect( - lrcInstance_->getCurrentCallModel(), + currentCallModel, &NewCallModel::endRemovePendingConferenceesRows, this, [this]() { endRemoveRows(); }, -- GitLab