diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2019-01-18 16:56:54 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2019-01-18 16:56:54 +0100 |
commit | 9e73d0dac0774955348a5164087363c5b33927b8 (patch) | |
tree | 61eb5d729c4e48e1fabe596f387a3e67a1d1d415 /lib/webprofile | |
parent | Rewrite lib/web to lib/webprofile (diff) | |
download | smolbote-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 'lib/webprofile')
-rw-r--r-- | lib/webprofile/webprofilemanager.cpp | 5 | ||||
-rw-r--r-- | lib/webprofile/webprofilemanager.h | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/webprofile/webprofilemanager.cpp b/lib/webprofile/webprofilemanager.cpp index d22b75c..2fca224 100644 --- a/lib/webprofile/webprofilemanager.cpp +++ b/lib/webprofile/webprofilemanager.cpp @@ -27,8 +27,9 @@ WebProfileManager::~WebProfileManager() if(!p.ptr->cachePath().isEmpty()) QDir(p.ptr->cachePath()).removeRecursively(); } + const QString filename = p.settings->fileName(); delete p.settings; - QFile::remove(p.settings->fileName()); + QFile::remove(filename); } else if(p.settings != nullptr) { #ifdef QT_DEBUG qDebug("sync %s", qUtf8Printable(p.settings->fileName())); @@ -132,7 +133,7 @@ void WebProfileManager::deleteProfile(const QString &id) } } -void WebProfileManager::profileMenu(QMenu *menu, std::function<void(WebProfile *)> callback, WebProfile *current, bool checkable) const +void WebProfileManager::profileMenu(QMenu *menu, const std::function<void(WebProfile *)> &callback, WebProfile *current, bool checkable) const { auto *group = new QActionGroup(menu); connect(menu, &QMenu::aboutToHide, group, &QActionGroup::deleteLater); diff --git a/lib/webprofile/webprofilemanager.h b/lib/webprofile/webprofilemanager.h index 822dc7d..f7bf52a 100644 --- a/lib/webprofile/webprofilemanager.h +++ b/lib/webprofile/webprofilemanager.h @@ -39,7 +39,7 @@ public: */ void deleteProfile(const QString &id); - void profileMenu(QMenu *menu, std::function<void(WebProfile *)> callback, WebProfile *current = nullptr, bool checkable = false) const; + void profileMenu(QMenu *menu, const std::function<void(WebProfile *)> &callback, WebProfile *current = nullptr, bool checkable = false) const; const QStringList idList() const { |