┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests/dolphinmainwindowtest.cpp
diff options
context:
space:
mode:
authorMāris Nartišs <[email protected]>2026-03-18 10:56:36 +0000
committerMéven Car <[email protected]>2026-03-18 10:56:36 +0000
commita7810673de828fec0861c11062491adaa85c8a00 (patch)
tree3fa74b0ee96cb0e8bcd2526f4407937ff81f74a0 /src/tests/dolphinmainwindowtest.cpp
parenta7cc959d5f1311ae928dd077b376570351ef5259 (diff)
DolphinTabPage: Prevent re-entrant signal activation for slotViewActivated
When switching tabs with split view enabled and the filter bar visible, a storm of activation calls is triggered and at the end signal/slot connections for both views is a mess (no listeners, navigation buttons linked to unfocused view etc.). Disconnect DolphinTabPage slot when it changes its own state. BUG: 508554, 512011, 508405, 511076, 503576
Diffstat (limited to 'src/tests/dolphinmainwindowtest.cpp')
-rw-r--r--src/tests/dolphinmainwindowtest.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp
index 26bb52a8e..a1727afdb 100644
--- a/src/tests/dolphinmainwindowtest.cpp
+++ b/src/tests/dolphinmainwindowtest.cpp
@@ -71,6 +71,7 @@ private Q_SLOTS:
void testThumbnailAfterRename();
void testViewModeAfterDynamicView();
void testActivationAndTabTitleAfterRenameOpeningFolder();
+ void testActiveViewAfterTabSwitchWithSplitView();
void cleanupTestCase();
private:
@@ -1292,6 +1293,53 @@ void DolphinMainWindowTest::testActivationAndTabTitleAfterRenameOpeningFolder()
QCOMPARE(tabWidget->tabText(1), expectedNewTab1Title);
}
+// Test that switching tabs does not spuriously toggle which split-view pane is active.
+// Regression test for the bug where DolphinTabPage::setActive(true) during tab switch
+// caused DolphinView::activated() to reach slotViewActivated(), which toggled
+// m_primaryViewActive and connected MainWindow signals to the wrong view container.
+void DolphinMainWindowTest::testActiveViewAfterTabSwitchWithSplitView()
+{
+ m_mainWindow->openDirectories({QUrl::fromLocalFile(QDir::homePath())}, false);
+ m_mainWindow->show();
+ QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data()));
+ QVERIFY(m_mainWindow->isVisible());
+
+ auto tabWidget = m_mainWindow->findChild<DolphinTabWidget *>("tabWidget");
+ QVERIFY(tabWidget);
+
+ // Enable split view on the first tab. After this, the secondary (right) pane
+ // becomes active via slotViewActivated(), so primaryViewActive() is false.
+ m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
+ QVERIFY(tabWidget->currentTabPage()->splitViewEnabled());
+ QVERIFY(!tabWidget->currentTabPage()->primaryViewActive());
+ auto firstTabPage = tabWidget->currentTabPage();
+ auto firstTabSecondary = firstTabPage->secondaryViewContainer();
+ QVERIFY(firstTabSecondary->isActive());
+
+ // Open a second tab and switch to it.
+ tabWidget->openNewActivatedTab(QUrl::fromLocalFile(QDir::homePath()));
+ QCOMPARE(tabWidget->count(), 2);
+ QCOMPARE(tabWidget->currentIndex(), 1);
+
+ // Spy on activeViewChanged to count emissions during the tab switch back.
+ QSignalSpy activeViewChangedSpy(tabWidget, &DolphinTabWidget::activeViewChanged);
+
+ // Switch back to the first tab.
+ tabWidget->setCurrentIndex(0);
+ QCOMPARE(tabWidget->currentTabPage(), firstTabPage);
+
+ // activeViewChanged must be emitted exactly once — by currentTabChanged itself.
+ // A spurious second emission would indicate slotViewActivated() fired during
+ // the programmatic setActive(true) and toggled m_primaryViewActive.
+ QCOMPARE(activeViewChangedSpy.count(), 1);
+
+ // The secondary pane must still be the designated active one.
+ QVERIFY(!firstTabPage->primaryViewActive());
+ QCOMPARE(firstTabPage->activeViewContainer(), firstTabSecondary);
+ QVERIFY(firstTabSecondary->isActive());
+ QVERIFY(!firstTabPage->primaryViewContainer()->isActive());
+}
+
void DolphinMainWindowTest::cleanupTestCase()
{
m_mainWindow->showNormal();