Skip to content

Commit

Permalink
Fix crash when loading a favorite with a not found site (fix #2695)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed May 30, 2022
1 parent 372976c commit da182ed
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/src/models/favorite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QSize>
#include <utility>
#include "functions.h"
#include "logger.h"
#include "models/profile.h"
#include "models/site.h"

Expand Down Expand Up @@ -159,8 +160,13 @@ Favorite Favorite::fromJson(const QString &path, const QJsonObject &json, Profil
const QMap<QString, Site*> &siteMap = profile->getSites();
QJsonArray jsonSites = json["sites"].toArray();
sites.reserve(jsonSites.count());
for (auto site : jsonSites) {
sites.append(siteMap.value(site.toString()));
for (auto jsonSite : jsonSites) {
const QString site = jsonSite.toString();
if (siteMap.contains(site)) {
sites.append(siteMap.value(site));
} else {
log(QStringLiteral("Invalid source found for monitor: %1").arg(site), Logger::Error);
}
}
}

Expand Down

0 comments on commit da182ed

Please sign in to comment.