From 765f33e796dbc1e8c5fefd77c9cf4cdf58a99a83 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 11 Jun 2017 16:00:31 +0200 Subject: Fixed crash when closing last tab --- src/mainwindow.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 851ee9e..861f7cf 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -35,7 +35,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : ui(new Ui::MainWindow), navigationToolBar(new QToolBar(tr("Navigation"), this)), tabToolBar(new QToolBar(tr("Tab bar"), this)), - tabBar(new WebViewTabBar(this)), + tabBar(new WebViewTabBar(nullptr, this)), urlLineEdit(new UrlLineEdit(navigationToolBar)), progressBar(new LoadingBar(this)) { @@ -91,6 +91,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : // Load profile m_profile = qApp->profile(sSettings->value("browser.profile.default").toString()); + tabBar->setProfile(m_profile); // loading bar ui->statusBar->addPermanentWidget(progressBar); @@ -148,9 +149,9 @@ void MainWindow::addTabbedDock(Qt::DockWidgetArea area, QDockWidget *widget) void MainWindow::newTab(const QUrl &url) { if(!url.isEmpty()) { - tabBar->addTab(m_profile, url); + tabBar->addTab(url); } else { - tabBar->addTab(m_profile, sSettings->value("general.newtab").toUrl()); + tabBar->addTab(sSettings->value("general.newtab").toUrl()); } } @@ -202,11 +203,14 @@ void MainWindow::handleTabChanged(WebView *view) { Q_ASSERT(view); - // clear the parent of the central widget so it doesn't get deleted - centralWidget()->setParent(0); + // centralWidget can be a nullptr + if(centralWidget()) { + // clear the parent of the central widget so it doesn't get deleted + centralWidget()->setParent(0); - // disconnect signals - disconnect(centralWidget()); + // disconnect signals + disconnect(centralWidget()); + } // set new central widget setCentralWidget(view); -- cgit v1.2.1