aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-05-31 13:52:38 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-05-31 13:52:38 +0200
commita7c43995c3a47bbbac8d862f69f9229eb39f4ed6 (patch)
tree6881a5d9d1dce4990ed094fddc9c059271570f2c /lib
parent6e27a49fbbc58a7310753f882fe372ddb0f63e33 (diff)
downloadlibquotient-a7c43995c3a47bbbac8d862f69f9229eb39f4ed6.tar.gz
libquotient-a7c43995c3a47bbbac8d862f69f9229eb39f4ed6.zip
AccountRegistry: fix dropping an inexistent Connection
On Debug builds this would lead to an assertion failure inside Qt.
Diffstat (limited to 'lib')
-rw-r--r--lib/accountregistry.cpp9
1 files changed, 5 insertions, 4 deletions
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));
}