diff options
| author | Māris Nartišs <[email protected]> | 2026-03-18 10:56:36 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-03-18 10:56:36 +0000 |
| commit | a7810673de828fec0861c11062491adaa85c8a00 (patch) | |
| tree | 3fa74b0ee96cb0e8bcd2526f4407937ff81f74a0 /src/dolphintabpage.cpp | |
| parent | a7cc959d5f1311ae928dd077b376570351ef5259 (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/dolphintabpage.cpp')
| -rw-r--r-- | src/dolphintabpage.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp index ca47130c0..f4922bf70 100644 --- a/src/dolphintabpage.cpp +++ b/src/dolphintabpage.cpp @@ -60,7 +60,13 @@ DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, m_secondaryViewContainer->show(); } + // DolphinView::setActive(true) calls setFocus() then emits activated(). + // activated() is connected to slotViewActivated() which toggles + // m_primaryViewActive — correct for user-initiated pane switches, but + // wrong here during construction. Disconnect to prevent the spurious toggle. + disconnectViewActivatedSignals(); m_primaryViewContainer->setActive(true); + connectViewActivatedSignals(); } bool DolphinTabPage::primaryViewActive() const @@ -364,12 +370,22 @@ void DolphinTabPage::restoreState(const QByteArray &state) } stream >> m_primaryViewActive; + // DolphinView::setActive(true) calls setFocus() then emits activated(). + // activated() is connected to slotViewActivated() which toggles + // m_primaryViewActive — correct for user-initiated pane switches, but + // wrong here during session restore. Disconnect to prevent the spurious toggle. + disconnectViewActivatedSignals(); if (m_primaryViewActive) { + if (m_splitViewEnabled) { + m_secondaryViewContainer->setActive(false); + } m_primaryViewContainer->setActive(true); } else { Q_ASSERT(m_splitViewEnabled); + m_primaryViewContainer->setActive(false); m_secondaryViewContainer->setActive(true); } + connectViewActivatedSignals(); QByteArray splitterState; stream >> splitterState; @@ -393,8 +409,16 @@ void DolphinTabPage::setActive(bool active) // we should bypass changing active view in split mode m_active = !m_splitViewEnabled; } - // we want view to fire activated when goes from false to true + // DolphinView::setActive(true) calls setFocus() then emits activated(). + // activated() is connected to slotViewActivated() which toggles + // m_primaryViewActive — correct for user-initiated pane switches, but + // wrong here during tab switch. Disconnect to prevent the spurious toggle. + disconnectViewActivatedSignals(); + if (active && m_splitViewEnabled) { + inactiveViewContainer()->setActive(false); + } activeViewContainer()->setActive(active); + connectViewActivatedSignals(); } void DolphinTabPage::setCustomLabel(const QString &label) @@ -518,6 +542,22 @@ void DolphinTabPage::switchActiveView() } } +void DolphinTabPage::connectViewActivatedSignals() +{ + connect(m_primaryViewContainer->view(), &DolphinView::activated, this, &DolphinTabPage::slotViewActivated); + if (m_secondaryViewContainer) { + connect(m_secondaryViewContainer->view(), &DolphinView::activated, this, &DolphinTabPage::slotViewActivated); + } +} + +void DolphinTabPage::disconnectViewActivatedSignals() +{ + disconnect(m_primaryViewContainer->view(), &DolphinView::activated, this, &DolphinTabPage::slotViewActivated); + if (m_secondaryViewContainer) { + disconnect(m_secondaryViewContainer->view(), &DolphinView::activated, this, &DolphinTabPage::slotViewActivated); + } +} + DolphinViewContainer *DolphinTabPage::createViewContainer(const QUrl &url) const { DolphinViewContainer *container = new DolphinViewContainer(url, m_splitter); |
