From d721f72a9bd98775dd91a4d00a9b5695484946eb Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Fri, 22 Sep 2023 19:51:25 +0000 Subject: [PATCH] Iterate KFilePlacesModel instead of using closestItem to remove SFTP entries Fixes bug where we could miss entries due to `closestItem()` skipping hidden items. It is also more performant. BUG: 461872 --- plugins/sftp/sftpplugin.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/sftp/sftpplugin.cpp b/plugins/sftp/sftpplugin.cpp index e1428642d..878dc3394 100644 --- a/plugins/sftp/sftpplugin.cpp +++ b/plugins/sftp/sftpplugin.cpp @@ -49,10 +49,13 @@ void SftpPlugin::addToDolphin() void SftpPlugin::removeFromDolphin() { QUrl kioUrl(QStringLiteral("kdeconnect://") + deviceId + QStringLiteral("/")); - QModelIndex index = m_placesModel.closestItem(kioUrl); - while (index.row() != -1) { - m_placesModel.removePlace(index); - index = m_placesModel.closestItem(kioUrl); + for (int i = 0; i < m_placesModel.rowCount(); ++i) { + QModelIndex index = m_placesModel.index(i, 0); + QUrl url = m_placesModel.url(index); + if (url == kioUrl) { + m_placesModel.removePlace(index); + --i; + } } }