aboutsummaryrefslogtreecommitdiff
path: root/lib
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 /lib
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 'lib')
-rw-r--r--lib/about/aboutplugin.cpp2
-rw-r--r--lib/bookmarks/bookmarkswidget.cpp2
-rw-r--r--lib/bookmarks/bookmarkswidget.h2
-rw-r--r--lib/bookmarks/xbel.h2
-rw-r--r--lib/urlfilter/hostlist/hostlist.cpp4
-rw-r--r--lib/webprofile/webprofilemanager.cpp5
-rw-r--r--lib/webprofile/webprofilemanager.h2
7 files changed, 10 insertions, 9 deletions
diff --git a/lib/about/aboutplugin.cpp b/lib/about/aboutplugin.cpp
index b2fab51..b345b75 100644
--- a/lib/about/aboutplugin.cpp
+++ b/lib/about/aboutplugin.cpp
@@ -30,7 +30,7 @@ QTreeWidgetItem *createItem(const QString &key, const QJsonValue &json, QTreeWid
case QJsonValue::Array:
item->setText(1, QString());
- for(const QJsonValue &v : json.toArray()) {
+ for(const auto &v : json.toArray()) {
createItem(QString(), v, item);
}
break;
diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp
index 045b424..f3ef4df 100644
--- a/lib/bookmarks/bookmarkswidget.cpp
+++ b/lib/bookmarks/bookmarkswidget.cpp
@@ -135,7 +135,7 @@ void BookmarksWidget::addBookmark(const QString &title, const QString &url)
model->appendBookmark(title, url, QModelIndex());
}
-void BookmarksWidget::search(const QString &term, std::function<void(QStringList &)> callback) const
+void BookmarksWidget::search(const QString &term, const std::function<void(QStringList &)> &callback) const
{
QStringList ret = model->search(term);
callback(ret);
diff --git a/lib/bookmarks/bookmarkswidget.h b/lib/bookmarks/bookmarkswidget.h
index f30db7d..149d2a6 100644
--- a/lib/bookmarks/bookmarkswidget.h
+++ b/lib/bookmarks/bookmarkswidget.h
@@ -39,7 +39,7 @@ signals:
public slots:
void save();
void addBookmark(const QString &title, const QString &url);
- void search(const QString &term, std::function<void(QStringList &)> callback) const;
+ void search(const QString &term, const std::function<void(QStringList &)> &callback) const;
private:
Ui::BookmarksDialog *ui;
diff --git a/lib/bookmarks/xbel.h b/lib/bookmarks/xbel.h
index 97a6ed4..44a65bb 100644
--- a/lib/bookmarks/xbel.h
+++ b/lib/bookmarks/xbel.h
@@ -13,7 +13,7 @@ class QIODevice;
class BookmarkItem;
namespace Xbel
{
-void read(QIODevice *device, BookmarkItem *model);
+void read(QIODevice *device, BookmarkItem *item);
void write(QIODevice *device, const BookmarkItem *item);
}
diff --git a/lib/urlfilter/hostlist/hostlist.cpp b/lib/urlfilter/hostlist/hostlist.cpp
index ec0b214..ff652cf 100644
--- a/lib/urlfilter/hostlist/hostlist.cpp
+++ b/lib/urlfilter/hostlist/hostlist.cpp
@@ -62,11 +62,11 @@ void HostList::parseLine(const QString& line)
return;
const QStringList parts = parsedLine.split(QLatin1Literal(" "));
- const QString redirect = parts.at(0);
+ const QString &redirect = parts.at(0);
const auto action = (redirect == QLatin1Literal("0.0.0.0")) ? UrlFilter::Block : UrlFilter::Redirect;
for(int i = 1; i < parts.size(); i++) {
- const QString domain = parts.at(i);
+ const QString &domain = parts.at(i);
Rule r;
r.action = action;
r.domainHash = qHash(domain);
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
{