From cb4012c5c94cc7768f08de204cb2143b0504a52b Mon Sep 17 00:00:00 2001 From: David Rosca Date: Fri, 7 Apr 2017 12:36:42 +0200 Subject: [PATCH] Don't save qupzilla:restore tabs in sessions --- src/lib/tabwidget/tabwidget.cpp | 22 ++++++++++++++++------ src/lib/webtab/webtab.cpp | 4 ++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index 18e4858c6..613beadc9 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -780,6 +780,7 @@ QList TabWidget::allTabs(bool withPinned) QByteArray TabWidget::saveState() { + int currentTabIndex = 0; QVector tabList; for (int i = 0; i < count(); ++i) { @@ -788,20 +789,29 @@ QByteArray TabWidget::saveState() continue; WebTab::SavedTab tab(webTab); + if (!tab.isValid()) + continue; + tabList.append(tab); + + if (webTab->isCurrentTab()) + currentTabIndex = tabList.size() - 1; } QByteArray data; - QDataStream stream(&data, QIODevice::WriteOnly); - stream << tabList.count(); + if (!tabList.isEmpty()) { + QDataStream stream(&data, QIODevice::WriteOnly); - foreach (const WebTab::SavedTab &tab, tabList) { - stream << tab; + stream << tabList.count(); + + foreach (const WebTab::SavedTab &tab, tabList) { + stream << tab; + } + + stream << currentTabIndex; } - stream << currentIndex(); - return data; } diff --git a/src/lib/webtab/webtab.cpp b/src/lib/webtab/webtab.cpp index 2edd83223..ed9be4373 100644 --- a/src/lib/webtab/webtab.cpp +++ b/src/lib/webtab/webtab.cpp @@ -47,6 +47,10 @@ WebTab::SavedTab::SavedTab() WebTab::SavedTab::SavedTab(WebTab* webTab) { + if (webTab->url().toString() == QL1S("qupzilla:restore")) { + return; + } + title = webTab->title(); url = webTab->url(); icon = webTab->icon(true);