aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainwindow.cpp2
-rw-r--r--src/widgets/webviewtabbar.cpp13
-rw-r--r--src/widgets/webviewtabbar.h7
3 files changed, 14 insertions, 8 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 30751d5..18c1e14 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -203,6 +203,8 @@ void MainWindow::handleNewWindow(const QUrl &url)
void MainWindow::handleTabChanged(WebView *view)
{
+ Q_ASSERT(view);
+
// clear the parent of the central widget so it doesn't get deleted
centralWidget()->setParent(0);
diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp
index fa8a0e8..c482eb3 100644
--- a/src/widgets/webviewtabbar.cpp
+++ b/src/widgets/webviewtabbar.cpp
@@ -28,7 +28,7 @@ WebViewTabBar::WebViewTabBar(QWidget *parent) :
setElideMode(Qt::ElideRight);
setTabsClosable(true);
setMovable(true);
- connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(handleTabClose(int)));
+ connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(removeTab(int)));
connect(this, SIGNAL(currentChanged(int)), this, SLOT(handleCurrentChanged(int)));
connect(this, SIGNAL(tabMoved(int,int)), this, SLOT(updateVectorArrangement(int,int)));
@@ -36,7 +36,7 @@ WebViewTabBar::WebViewTabBar(QWidget *parent) :
QAction *tabCloseAction = new QAction(this);
tabCloseAction->setShortcut(QKeySequence::fromString(sSettings->value("window.shortcuts.tabClose").toString()));
connect(tabCloseAction, &QAction::triggered, [this]() {
- this->handleTabClose(currentIndex());
+ this->removeTab(currentIndex());
});
addAction(tabCloseAction);
}
@@ -111,12 +111,15 @@ void WebViewTabBar::handleCurrentChanged(int index)
emit currentTabChanged(m_views.at(index));
}
-void WebViewTabBar::handleTabClose(int index)
+void WebViewTabBar::removeTab(int index)
{
- qDebug("removing tab %i", index);
- removeTab(index);
+ // remove the tab data from the index
m_views.at(index)->deleteLater();
m_views.remove(index);
+
+ // remove the tab from the QTabBar
+ // this emits the currentTabChanged signal, so it should be done after the view is removed from the index
+ QTabBar::removeTab(index);
}
void WebViewTabBar::updateTabText(WebView *view, const QString &text)
diff --git a/src/widgets/webviewtabbar.h b/src/widgets/webviewtabbar.h
index 9029bf5..91e55d0 100644
--- a/src/widgets/webviewtabbar.h
+++ b/src/widgets/webviewtabbar.h
@@ -32,20 +32,21 @@ public:
WebViewTabBar(QWidget *parent = 0);
~WebViewTabBar();
- int addTab(QWebEngineProfile *profile, const QUrl &url);
void setProfile(QWebEngineProfile *profile);
-
WebView *currentView();
signals:
void currentTabChanged(WebView *view);
+public slots:
+ int addTab(QWebEngineProfile *profile, const QUrl &url);
+ void removeTab(int index);
+
protected:
QSize tabSizeHint(int index) const;
private slots:
void handleCurrentChanged(int index);
- void handleTabClose(int index);
void updateTabText(WebView *view, const QString &text);
void updateVectorArrangement(int from, int to);