aboutsummaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-02-27 16:02:49 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-02-27 16:02:49 +0100
commit5b75e14696c9d0452e6e393b61ccf74399665d64 (patch)
tree1d579e0799fe773fd978519669703b741f77438f /src/widgets
parentinstalling config file (diff)
downloadsmolbote-5b75e14696c9d0452e6e393b61ccf74399665d64.tar.xz
Fixed crash when closing the first tab
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/webviewtabbar.cpp13
-rw-r--r--src/widgets/webviewtabbar.h7
2 files changed, 12 insertions, 8 deletions
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);