aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2019-01-18 16:56:54 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2019-01-18 16:56:54 +0100
commit9e73d0dac0774955348a5164087363c5b33927b8 (patch)
tree61eb5d729c4e48e1fabe596f387a3e67a1d1d415 /src/mainwindow
parentRewrite lib/web to lib/webprofile (diff)
downloadsmolbote-9e73d0dac0774955348a5164087363c5b33927b8.tar.xz
Add tools/report-clang-tidy.sh
- Fix various clang-tidy warnings - Fix use-after-free crash when deleting profiles
Diffstat (limited to 'src/mainwindow')
-rw-r--r--src/mainwindow/mainwindow.cpp16
-rw-r--r--src/mainwindow/menubar.cpp4
2 files changed, 10 insertions, 10 deletions
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<Configuration> &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<Configuration> &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 <functional>
#include <QVBoxLayout>
-inline void run_if(SubWindow *_subwindow, std::function<void(SubWindow*, int)> f)
+inline void run_if(SubWindow *_subwindow, const std::function<void(SubWindow*, int)> &f)
{
if(_subwindow != nullptr)
f(_subwindow, _subwindow->currentTabIndex());
@@ -111,7 +111,7 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
const QString sessionPath = config->value<QString>("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");