From 9e73d0dac0774955348a5164087363c5b33927b8 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 18 Jan 2019 16:56:54 +0100 Subject: Add tools/report-clang-tidy.sh - Fix various clang-tidy warnings - Fix use-after-free crash when deleting profiles --- src/mainwindow/mainwindow.cpp | 16 ++++++++-------- src/mainwindow/menubar.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/mainwindow') diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 71b594a..7fb7d9e 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -69,7 +69,7 @@ MainWindow::MainWindow(const std::unique_ptr &config, QWidget *pa config->setShortcut(subwindowMenuAction, "subwindow.shortcuts.menu"); connect(subwindowMenuAction, &QAction::triggered, this, [this]() { QMdiSubWindow *window = mdiArea->currentSubWindow(); - if(window) { + if(window != nullptr) { // show the menu at the subwindow position // position has to be global, and mapped by the mdiArea (parentWidget() of the subwindow) const auto position = mdiArea->mapToGlobal(window->pos()); @@ -114,20 +114,20 @@ MainWindow::MainWindow(const std::unique_ptr &config, QWidget *pa // address bar connect(addressBar, &AddressBar::search, this, [this](const QString &term) { - if(this->currentView) { + if(this->currentView != nullptr) { currentView->search(term); currentView->setFocus(); } }); connect(addressBar, &AddressBar::load, this, [this](const QUrl &url) { - if(this->currentView) { + if(this->currentView != nullptr) { currentView->load(url); currentView->setFocus(); } }); connect(addressBar, &AddressBar::giveFocus, this, [this]() { - if(this->currentView) { + if(this->currentView != nullptr) { currentView->setFocus(); } }); @@ -244,13 +244,13 @@ SubWindow *MainWindow::createSubWindow(WebProfile *profile, bool openProfileNewt void MainWindow::setView(WebView *view) { - if(currentView) { + if(currentView != nullptr) { // disconnect old view - disconnect(currentView, 0, addressBar, 0); + disconnect(currentView, nullptr, addressBar, nullptr); } currentView = view; - if(view) { + if(view != nullptr) { connect(view, &WebView::urlChanged, addressBar, &AddressBar::setUrl); addressBar->setUrl(view->url()); @@ -277,7 +277,7 @@ void MainWindow::closeEvent(QCloseEvent *event) } mdiArea->closeAllSubWindows(); - if(mdiArea->currentSubWindow()) + if(mdiArea->currentSubWindow() != nullptr) event->ignore(); else event->accept(); diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp index 117641f..7b7d912 100644 --- a/src/mainwindow/menubar.cpp +++ b/src/mainwindow/menubar.cpp @@ -30,7 +30,7 @@ #include #include -inline void run_if(SubWindow *_subwindow, std::function f) +inline void run_if(SubWindow *_subwindow, const std::function &f) { if(_subwindow != nullptr) f(_subwindow, _subwindow->currentTabIndex()); @@ -111,7 +111,7 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent) const QString sessionPath = config->value("browser.session.path").value(); auto *actionSaveSession = smolbote->addAction(tr("Save Session"), parent, [sessionPath]() { auto *sessionDialog = new SaveSessionDialog(nullptr); - if(sessionDialog->exec()) + if(sessionDialog->exec() == QDialog::Accepted) sessionDialog->save(sessionPath); }); config->setShortcut(actionSaveSession, "mainwindow.shortcuts.saveSession"); -- cgit v1.2.1