diff options
| author | Amol Godbole <[email protected]> | 2023-11-09 11:17:33 -0600 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2024-01-14 08:34:58 +0000 |
| commit | 5a8bd47296e204a68014a60757758c50fa623526 (patch) | |
| tree | b595e21caf4c0c51ae2e86f659c3514e89ef4293 | |
| parent | c035e95e1d74fecd8267b08009c616232e2c16b0 (diff) | |
DolphinView: Use SingleShot and Queued Connections
A minor refactor where Qt::SingleShotConnection has been utilized.
Also, signal delay using QTimer has been replaced with a
Qt::QueuedConnection.
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 7 | ||||
| -rw-r--r-- | src/views/dolphinview.cpp | 22 |
2 files changed, 13 insertions, 16 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 5f4f0bb9a..939f66157 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -1196,12 +1196,7 @@ void KFileItemModel::slotItemsDeleted(const KFileItemList &items) for (const KFileItem &item : items) { if (item.url() == currentDir) { - // #473377: Delay emitting currentDirectoryRemoved() to avoid modifying KCoreDirLister - // before KCoreDirListerCache::deleteDir() returns. - QTimer::singleShot(0, this, [this] { - Q_EMIT currentDirectoryRemoved(); - }); - + Q_EMIT currentDirectoryRemoved(); return; } diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 6b77a46ea..ae0aa903c 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -200,7 +200,8 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent) connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection); connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError); connect(m_model, &KFileItemModel::fileItemsChanged, this, &DolphinView::fileItemsChanged); - connect(m_model, &KFileItemModel::currentDirectoryRemoved, this, &DolphinView::currentDirectoryRemoved); + // #473377: Use a QueuedConnection to avoid modifying KCoreDirLister before KCoreDirListerCache::deleteDir() returns. + connect(m_model, &KFileItemModel::currentDirectoryRemoved, this, &DolphinView::currentDirectoryRemoved, Qt::QueuedConnection); connect(this, &DolphinView::itemCountChanged, this, &DolphinView::updatePlaceholderLabel); @@ -740,17 +741,18 @@ void DolphinView::renameSelectedItems() if (items.count() == 1 && GeneralSettings::renameInline()) { const int index = m_model->index(items.first()); - QMetaObject::Connection *const connection = new QMetaObject::Connection; - *connection = connect(m_view, &KItemListView::scrollingStopped, this, [=]() { - QObject::disconnect(*connection); - delete connection; - - m_view->editRole(index, "text"); + connect( + m_view, + &KItemListView::scrollingStopped, + this, + [this, index]() { + m_view->editRole(index, "text"); - hideToolTip(); + hideToolTip(); - connect(m_view, &DolphinItemListView::roleEditingFinished, this, &DolphinView::slotRoleEditingFinished); - }); + connect(m_view, &DolphinItemListView::roleEditingFinished, this, &DolphinView::slotRoleEditingFinished); + }, + Qt::SingleShotConnection); m_view->scrollToItem(index); } else { |
