diff --git a/src/lib/webtab/webtab.cpp b/src/lib/webtab/webtab.cpp index 4f96f8d6d..4ae55d578 100644 --- a/src/lib/webtab/webtab.cpp +++ b/src/lib/webtab/webtab.cpp @@ -34,6 +34,7 @@ #include #include +bool WebTab::s_pinningTab = false; static const int savedTabVersion = 2; WebTab::SavedTab::SavedTab() @@ -199,6 +200,8 @@ QWebEngineHistory* WebTab::history() const void WebTab::detach() { + Q_ASSERT(m_tabBar); + // Remove icon from tab m_tabBar->setTabButton(tabIndex(), m_tabBar->iconButtonPosition(), 0); @@ -377,7 +380,7 @@ void WebTab::showEvent(QShowEvent* event) { QWidget::showEvent(event); - if (!isRestored()) { + if (!isRestored() && !s_pinningTab) { // When session is being restored, restore the tab immediately if (mApp->isRestoring()) { slotRestore(); @@ -406,5 +409,10 @@ void WebTab::togglePinned() Q_ASSERT(m_window); m_isPinned = !m_isPinned; + + // Workaround bug in TabStackedWidget when pinning tab, other tabs may be accidentaly + // shown and restored state even when they won't be switched to by user. + s_pinningTab = true; m_window->tabWidget()->pinUnPinTab(tabIndex(), title()); + s_pinningTab = false; } diff --git a/src/lib/webtab/webtab.h b/src/lib/webtab/webtab.h index 79b35d050..087145633 100644 --- a/src/lib/webtab/webtab.h +++ b/src/lib/webtab/webtab.h @@ -116,6 +116,8 @@ private: SavedTab m_savedTab; bool m_isPinned; + + static bool s_pinningTab; }; #endif // WEBTAB_H