Browse Source

Use implicit sharing when getting categories from Session class

adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
e32ef7f5c5
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 2
      src/base/bittorrent/session.cpp
  2. 2
      src/base/bittorrent/session.h
  3. 2
      src/webui/api/synccontroller.cpp
  4. 4
      src/webui/api/torrentscontroller.cpp

2
src/base/bittorrent/session.cpp

@ -585,7 +585,7 @@ QStringList Session::expandCategory(const QString &category)
return result; return result;
} }
const QStringMap &Session::categories() const QStringMap Session::categories() const
{ {
return m_categories; return m_categories;
} }

2
src/base/bittorrent/session.h

@ -201,7 +201,7 @@ namespace BitTorrent
// returns category itself and all top level categories // returns category itself and all top level categories
static QStringList expandCategory(const QString &category); static QStringList expandCategory(const QString &category);
const QStringMap &categories() const; QStringMap categories() const;
QString categorySavePath(const QString &categoryName) const; QString categorySavePath(const QString &categoryName) const;
bool addCategory(const QString &name, const QString &savePath = ""); bool addCategory(const QString &name, const QString &savePath = "");
bool editCategory(const QString &name, const QString &savePath); bool editCategory(const QString &name, const QString &savePath);

2
src/webui/api/synccontroller.cpp

@ -446,7 +446,7 @@ void SyncController::maindataAction()
data["torrents"] = torrents; data["torrents"] = torrents;
QVariantHash categories; QVariantHash categories;
const auto &categoriesList = session->categories(); const QStringMap categoriesList = session->categories();
for (auto it = categoriesList.cbegin(); it != categoriesList.cend(); ++it) { for (auto it = categoriesList.cbegin(); it != categoriesList.cend(); ++it) {
const QString &key = it.key(); const QString &key = it.key();
categories[key] = QVariantMap { categories[key] = QVariantMap {

4
src/webui/api/torrentscontroller.cpp

@ -1077,8 +1077,8 @@ void TorrentsController::removeCategoriesAction()
void TorrentsController::categoriesAction() void TorrentsController::categoriesAction()
{ {
QJsonObject categories; QJsonObject categories;
const auto categoriesList = BitTorrent::Session::instance()->categories(); const QStringMap categoriesMap = BitTorrent::Session::instance()->categories();
for (auto it = categoriesList.cbegin(); it != categoriesList.cend(); ++it) { for (auto it = categoriesMap.cbegin(); it != categoriesMap.cend(); ++it) {
const auto &key = it.key(); const auto &key = it.key();
categories[key] = QJsonObject { categories[key] = QJsonObject {
{"name", key}, {"name", key},

Loading…
Cancel
Save