From a560b7f498456090b51ac3ee2748cc0a24100b94 Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 8 Apr 2014 15:47:48 +0200 Subject: [PATCH] [TabWidget] Make sure current tab is loaded on session restore Fixes issue with current tab not being loaded on session restore with "don't load tabs until selected" option. It was needed to switch to other tab and then switch back to first tab to actually load it. Also pause updates of the whole browser window when restoring session. --- src/lib/app/mainapplication.cpp | 9 +++++++-- src/lib/tabwidget/tabwidget.cpp | 21 +++++---------------- src/lib/tabwidget/tabwidget.h | 1 - 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index a3fe5c92c..8baba219f 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -361,6 +361,7 @@ bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreD m_isRestoring = true; setOverrideCursor(Qt::BusyCursor); + window->setUpdatesEnabled(false); window->tabWidget()->closeRecoveryTab(); if (window->tabWidget()->normalTabsCount() > 1) { @@ -369,9 +370,10 @@ bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreD // Don't restore tabs in current window as user already opened // some new tabs. // Instead create new one and restore pinned tabs there - BrowserWindow* newWin = createWindow(Qz::BW_OtherRestoredWindow); + newWin->setUpdatesEnabled(false); newWin->restoreWindowState(restoreData.first()); + newWin->setUpdatesEnabled(true); restoreData.remove(0); } else { @@ -383,15 +385,18 @@ bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreD RestoreManager::WindowData data = restoreData.first(); data.currentTab += tabCount; restoreData.remove(0); - window->restoreWindowState(data); } + window->setUpdatesEnabled(true); + processEvents(); foreach (const RestoreManager::WindowData &data, restoreData) { BrowserWindow* window = createWindow(Qz::BW_OtherRestoredWindow); + window->setUpdatesEnabled(false); window->restoreWindowState(data); + window->setUpdatesEnabled(true); processEvents(); } diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index 1cfb23915..afcfe0cb8 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -117,7 +117,6 @@ TabWidget::TabWidget(BrowserWindow* window, QWidget* parent) , m_lastTabIndex(-1) , m_lastBackgroundTabIndex(-1) , m_isClosingToLastTabIndex(false) - , m_isRestoringState(false) { setObjectName(QSL("tabwidget")); @@ -331,8 +330,6 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N QtWin::extendFrameIntoClientArea(m_window); } #endif - setUpdatesEnabled(false); - QUrl url = req.url(); m_lastTabIndex = currentIndex(); @@ -412,8 +409,6 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N m_tabBar->ensureVisible(index); } - setUpdatesEnabled(true); - emit changed(); #ifdef Q_OS_WIN @@ -513,9 +508,8 @@ void TabWidget::closeTab(int index, bool force) void TabWidget::currentTabChanged(int index) { - if (!validIndex(index) || m_isRestoringState) { + if (!validIndex(index)) return; - } m_isClosingToLastTabIndex = m_lastBackgroundTabIndex == index; m_lastBackgroundTabIndex = -1; @@ -827,8 +821,6 @@ void TabWidget::restorePinnedTabs() QList tabHistory; stream >> tabHistory; - m_isRestoringState = true; - for (int i = 0; i < pinnedTabs.count(); ++i) { QUrl url = QUrl::fromEncoded(pinnedTabs.at(i).toUtf8()); @@ -852,8 +844,6 @@ void TabWidget::restorePinnedTabs() m_tabBar->updatePinnedTabCloseButton(addedIndex); } - - m_isRestoringState = false; } QByteArray TabWidget::saveState() @@ -886,8 +876,6 @@ QByteArray TabWidget::saveState() bool TabWidget::restoreState(const QVector &tabs, int currentTab) { - m_isRestoringState = true; - Qz::BrowserWindowType type = m_window->windowType(); if (type == Qz::BW_FirstAppWindow || type == Qz::BW_MacFirstWindow) { @@ -901,10 +889,11 @@ bool TabWidget::restoreState(const QVector &tabs, int currentT weTab(index)->restoreTab(tab); } - m_isRestoringState = false; - setCurrentIndex(currentTab); - currentTabChanged(currentTab); + + // WebTab is restoring state on showEvent + weTab()->hide(); + weTab()->show(); return true; } diff --git a/src/lib/tabwidget/tabwidget.h b/src/lib/tabwidget/tabwidget.h index c63c57356..ff5bfa676 100644 --- a/src/lib/tabwidget/tabwidget.h +++ b/src/lib/tabwidget/tabwidget.h @@ -156,7 +156,6 @@ private: int m_lastTabIndex; int m_lastBackgroundTabIndex; bool m_isClosingToLastTabIndex; - bool m_isRestoringState; bool m_dontCloseWithOneTab; bool m_showClosedTabsButton;