From 65d1493f0a2f7c178e33353bfaacdcc088081dfe Mon Sep 17 00:00:00 2001 From: David Rosca Date: Thu, 4 Jan 2018 20:50:17 +0100 Subject: [PATCH] Fix closing tabs - regression from last commits Closes #2534 --- src/lib/navigation/navigationbar.cpp | 2 +- src/lib/tabwidget/tabwidget.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/navigation/navigationbar.cpp b/src/lib/navigation/navigationbar.cpp index d9606e211..890a7efe7 100644 --- a/src/lib/navigation/navigationbar.cpp +++ b/src/lib/navigation/navigationbar.cpp @@ -317,7 +317,7 @@ void NavigationBar::reloadLayout() QSL("locationbar") }; - QStringList ids = Settings().value(QSL("NavigationBar/layout"), defaultIds).toStringList(); + QStringList ids = Settings().value(QSL("NavigationBar/Layout"), defaultIds).toStringList(); ids.removeDuplicates(); if (!ids.contains(QSL("locationbar"))) { ids.append(QSL("locationbar")); diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index bd6f0bd90..e02c1a592 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -346,7 +346,7 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N m_lastBackgroundTabIndex = index; } - connect(webTab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(requestCloseTab(int))); + connect(webTab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int))); connect(webTab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed())); connect(webTab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString))); connect(webTab->webView(), &WebView::urlChanged, this, [this](const QUrl &url) { @@ -393,7 +393,7 @@ int TabWidget::insertView(int index, WebTab *tab, const Qz::NewTabPositionFlags m_lastBackgroundTabIndex = index; } - connect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(requestCloseTab(int))); + connect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int))); connect(tab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed())); connect(tab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString))); @@ -425,11 +425,17 @@ void TabWidget::closeTab(int index) if (!webTab || !validIndex(index)) return; + // This is already handled in requestCloseTab + if (count() <= 1) { + requestCloseTab(index); + return; + } + m_closedTabsManager->saveTab(webTab); TabbedWebView *webView = webTab->webView(); m_locationBars->removeWidget(webView->webTab()->locationBar()); - disconnect(webView, SIGNAL(wantsCloseTab(int)), this, SLOT(requestCloseTab(int))); + disconnect(webView, SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int))); disconnect(webView, SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed())); disconnect(webView, SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString))); @@ -634,7 +640,7 @@ void TabWidget::detachTab(WebTab* tab) Q_ASSERT(tab); m_locationBars->removeWidget(tab->locationBar()); - disconnect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(requestCloseTab(int))); + disconnect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int))); disconnect(tab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed())); disconnect(tab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString)));