From a7c43995c3a47bbbac8d862f69f9229eb39f4ed6 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 31 May 2022 13:52:38 +0200 Subject: AccountRegistry: fix dropping an inexistent Connection On Debug builds this would lead to an assertion failure inside Qt. --- lib/accountregistry.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/accountregistry.cpp') diff --git a/lib/accountregistry.cpp b/lib/accountregistry.cpp index b40d5ecf..b3025fa4 100644 --- a/lib/accountregistry.cpp +++ b/lib/accountregistry.cpp @@ -21,10 +21,11 @@ void AccountRegistry::add(Connection* a) void AccountRegistry::drop(Connection* a) { - const auto idx = indexOf(a); - beginRemoveRows(QModelIndex(), idx, idx); - remove(idx); - endRemoveRows(); + if (const auto idx = indexOf(a); idx != -1) { + beginRemoveRows(QModelIndex(), idx, idx); + remove(idx); + endRemoveRows(); + } Q_ASSERT(!contains(a)); } -- cgit v1.2.3