From dde672ac944af64d09cbd90dffc3d513ffe0c2b7 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Mon, 14 Jan 2013 10:42:03 +0100 Subject: Don't delay popup menus of "Create New" and "Recently Closed Tabs" toolbar buttons REVIEW: 108397 --- src/dolphinmainwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 11e03d0f1..9454c8c42 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1484,6 +1484,7 @@ void DolphinMainWindow::setupActions() KMenu* menu = m_newFileMenu->menu(); menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); menu->setIcon(KIcon("document-new")); + m_newFileMenu->setDelayed(false); connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateNewMenu())); @@ -1577,6 +1578,7 @@ void DolphinMainWindow::setupActions() m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this); m_recentTabsMenu->setIcon(KIcon("edit-undo")); + m_recentTabsMenu->setDelayed(false); actionCollection()->addAction("closed_tabs", m_recentTabsMenu); connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction*)), this, SLOT(restoreClosedTab(QAction*))); -- cgit v1.3 From 256792355d01485eb148f8fb50f92e1c276cb769 Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Mon, 14 Jan 2013 20:01:03 +0100 Subject: Select right item as current item (first item after the deletion) after deleting files BUG: 290736 REVIEW: 108356 FIXED-IN: 4.10 --- src/kitemviews/kitemlistselectionmanager.cpp | 42 +++++++++++++++------------- src/kitemviews/kitemlistselectionmanager.h | 7 ++++- src/tests/kitemlistselectionmanagertest.cpp | 2 +- 3 files changed, 30 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/kitemviews/kitemlistselectionmanager.cpp b/src/kitemviews/kitemlistselectionmanager.cpp index 383914df0..833f7aad0 100644 --- a/src/kitemviews/kitemlistselectionmanager.cpp +++ b/src/kitemviews/kitemlistselectionmanager.cpp @@ -284,27 +284,23 @@ void KItemListSelectionManager::itemsRemoved(const KItemRangeList& itemRanges) { // Store the current selection (needed in the selectionChanged() signal) const QSet previousSelection = selectedItems(); + const int previousCurrent = m_currentItem; // Update the current item - if (m_currentItem >= 0) { - const int previousCurrent = m_currentItem; - // Calling setCurrentItem() would trigger the selectionChanged signal, but we want to - // emit it only once in this function -> change the current item manually and emit currentChanged - m_currentItem = indexAfterRangesRemoving(m_currentItem, itemRanges); - if (m_currentItem != previousCurrent) { - emit currentChanged(m_currentItem, previousCurrent); - } - + m_currentItem = indexAfterRangesRemoving(m_currentItem, itemRanges, DiscardRemovedIndex); + if (m_currentItem != previousCurrent) { + emit currentChanged(m_currentItem, previousCurrent); if (m_currentItem < 0) { - // The current item has been removed. - m_currentItem = qMin(previousCurrent, m_model->count() - 1); + // Calling setCurrentItem() would trigger the selectionChanged signal, but we want to + // emit it only once in this function -> change the current item manually and emit currentChanged + m_currentItem = indexAfterRangesRemoving(previousCurrent, itemRanges, AdjustRemovedIndex); emit currentChanged(m_currentItem, -1); } } // Update the anchor item if (m_anchorItem >= 0) { - m_anchorItem = indexAfterRangesRemoving(m_anchorItem, itemRanges); + m_anchorItem = indexAfterRangesRemoving(m_anchorItem, itemRanges, DiscardRemovedIndex); if (m_anchorItem < 0) { m_isAnchoredSelectionActive = false; } @@ -317,7 +313,7 @@ void KItemListSelectionManager::itemsRemoved(const KItemRangeList& itemRanges) m_selectedItems.reserve(previous.count()); QSetIterator it(previous); while (it.hasNext()) { - const int index = indexAfterRangesRemoving(it.next(), itemRanges); + const int index = indexAfterRangesRemoving(it.next(), itemRanges, DiscardRemovedIndex); if (index >= 0) { m_selectedItems.insert(index); } @@ -377,7 +373,8 @@ void KItemListSelectionManager::itemsMoved(const KItemRange& itemRange, const QL } } -int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRangeList& itemRanges) const +int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRangeList& itemRanges, + const RangesRemovingBehaviour behaviour) const { int dec = 0; foreach (const KItemRange& itemRange, itemRanges) { @@ -385,13 +382,20 @@ int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRa break; } - if (index < itemRange.index + itemRange.count) { + dec += itemRange.count; + + const int firstIndexAfterRange = itemRange.index + itemRange.count; + if (index < firstIndexAfterRange) { // The index is part of the removed range - return -1; + if (behaviour == DiscardRemovedIndex) { + return -1; + } else { + // Use the first item after the range as new index + index = firstIndexAfterRange; + break; + } } - - dec += itemRange.count; } - return index - dec; + return qBound(-1, index - dec, m_model->count() - 1); } #include "kitemlistselectionmanager.moc" diff --git a/src/kitemviews/kitemlistselectionmanager.h b/src/kitemviews/kitemlistselectionmanager.h index 43d0dcb80..c89b8a4b8 100644 --- a/src/kitemviews/kitemlistselectionmanager.h +++ b/src/kitemviews/kitemlistselectionmanager.h @@ -39,6 +39,11 @@ class LIBDOLPHINPRIVATE_EXPORT KItemListSelectionManager : public QObject { Q_OBJECT + enum RangesRemovingBehaviour { + DiscardRemovedIndex, + AdjustRemovedIndex + }; + public: enum SelectionMode { Select, @@ -81,7 +86,7 @@ private: * Helper method for itemsRemoved. Returns the changed index after removing * the given range. If the index is part of the range, -1 will be returned. */ - int indexAfterRangesRemoving(int index, const KItemRangeList& itemRanges) const; + int indexAfterRangesRemoving(int index, const KItemRangeList& itemRanges, const RangesRemovingBehaviour behaviour) const; private: int m_currentItem; diff --git a/src/tests/kitemlistselectionmanagertest.cpp b/src/tests/kitemlistselectionmanagertest.cpp index 3a8400930..302985a5f 100644 --- a/src/tests/kitemlistselectionmanagertest.cpp +++ b/src/tests/kitemlistselectionmanagertest.cpp @@ -499,7 +499,7 @@ void KItemListSelectionManagerTest::testDeleteCurrentItem_data() QTest::newRow("Remove before") << 50 << 0 << 10 << 40; QTest::newRow("Remove after") << 50 << 51 << 10 << 50; QTest::newRow("Remove exactly current item") << 50 << 50 << 1 << 50; - QTest::newRow("Remove around current item") << 50 << 45 << 10 << 50; + QTest::newRow("Remove around current item") << 50 << 45 << 10 << 45; QTest::newRow("Remove all except one item") << 50 << 1 << 99 << 0; } -- cgit v1.3 From e7fe50bd3d5a2a1f8427878086ff94deb31091bb Mon Sep 17 00:00:00 2001 From: Simeon Bird Date: Sun, 13 Jan 2013 13:49:21 -0500 Subject: A crash occurs if updateItemStates runs between the UpdateItemStatesThread finishing and the finished() signal being delivered. In this case, a new thread was not created, because the old thread still existed. However, pendingItemStatesUpdate was not set, because the thread was not running. Instead, the old thread was restarted. This meant that the finished() signal from the first run could be delivered while the thread was running for a second time, causing the thread to be deleted while still running and thus a crash. Solution: set pendingItemStatesUpdate if the thread is non-null, even if it is not running, knowing that slotThreadFinished has not yet run, and will call updateItemStates itself. BUG: 302264 FIXED-IN: 4.10 REVIEW: 107656 --- src/views/versioncontrol/versioncontrolobserver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp index 42e00de42..64bc26867 100644 --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@ -245,7 +245,7 @@ void VersionControlObserver::updateItemStates() connect(m_updateItemStatesThread, SIGNAL(finished()), m_updateItemStatesThread, SLOT(deleteLater())); } - if (m_updateItemStatesThread->isRunning()) { + else { // An update is currently ongoing. Wait until the thread has finished // the update (see slotThreadFinished()). m_pendingItemStatesUpdate = true; -- cgit v1.3