QupZilla / qupzilla

Cross-platform Qt web browser
http://www.qupzilla.com
GNU General Public License v3.0
1.11k stars 349 forks source link

Unloaded tab's page is lost when the tab is selected after closing another tab #2489

Closed elcste closed 6 years ago

elcste commented 6 years ago

I'm running Qupzilla 2.2.0 (QtWebEngine version 5.9.1) built from source on Ubuntu MATE 17.10.

With "After launch: Restore session" and "Don't load tabs until selected" activated, after I re-open QupZilla with several tabs, if I close an active tab next to an unloaded tab causing it to switch to the unload tab, the tab's save page is lost and I get "Empty page" in its place. This will keep happening if I keep closing a tab, while if I switch to another tab without closing one it loads OK.

Edit: I thought this was happening for me all the time, but now I've tried it some more and it only happened in some cases. I will try to find a pattern.

ghost commented 6 years ago

I also noticed that few days ago, but it realy happens from time to time...

nowrep commented 6 years ago

Most likely regression from 2b76b24eef265fd0f1137940a8317cce61cb3d34

srazi commented 6 years ago

@nowrep The issue happens since TabBar::currentTabChanged() is called twice:

495 TabWidget::requestCloseTab 4
272 ComboTabBar::slotCurrentChanged 1 TabBarHelper(0xbc69878, name = "tabbar")
377 TabBar::currentTabChanged 5 TabBar(0xb9e50a0, name = "tabbarwidget")
511 TabWidget::currentTabChanged 5
479 WebTab::tabActivated false
1028 TabBarHelper::removeTab BEFORE: QTabBar::removeTab() 0
272 ComboTabBar::slotCurrentChanged 0 TabBarHelper(0xbc69878, name = "tabbar")
377 TabBar::currentTabChanged 4 TabBar(0xb9e50a0, name = "tabbarwidget")
511 TabWidget::currentTabChanged 4
479 WebTab::tabActivated false
1030 TabBarHelper::removeTab AFTER: QTabBar::removeTab() 0
408 WebTab::p_restoreTab QUrl("https://travis-ci.org/QupZilla/qupzilla")
408 WebTab::p_restoreTab QUrl("")

The following patch fixes it, but I don't know why that if was there:

diff --git a/src/lib/tabwidget/combotabbar.cpp b/src/lib/tabwidget/combotabbar.cpp
index 1817f0f..f6151a1 100644
--- a/src/lib/tabwidget/combotabbar.cpp
+++ b/src/lib/tabwidget/combotabbar.cpp
@@ -1022,9 +1022,8 @@ void TabBarHelper::removeTab(int index)
 {
     // Removing tab in inactive tabbar will change current index and thus
     // changing active tabbar, which is really not wanted.
-    if (!m_activeTabBar)
-        m_comboTabBar->m_blockCurrentChangedSignal = true;
-
+    // Also removing tab will cause a duplicate call to ComboTabBar::slotCurrentChanged()
+    m_comboTabBar->m_blockCurrentChangedSignal = true;
     QTabBar::removeTab(index);

     m_comboTabBar->m_blockCurrentChangedSignal = false;