fixed json guessing

This commit is contained in:
Martin Rotter 2022-01-19 12:44:28 +01:00
parent 6bc7b9796b
commit 03d56b3054
2 changed files with 7 additions and 2 deletions

View File

@ -441,7 +441,7 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
}
QFontMetrics fm(data(idx, Qt::ItemDataRole::FontRole).value<QFont>());
auto rct = fm.boundingRect(QRect(QPoint(0, 0), QPoint(wd - 10, 100000)),
auto rct = fm.boundingRect(QRect(QPoint(0, 0), QPoint(wd - 5, 100000)),
Qt::TextFlag::TextWordWrap |
Qt::AlignmentFlag::AlignLeft |
Qt::AlignmentFlag::AlignVCenter,

View File

@ -295,7 +295,12 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
feed->setEncoding(QSL(DEFAULT_FEED_ENCODING));
feed->setType(Type::Json);
QJsonDocument json = QJsonDocument::fromJson(feed_contents);
QJsonParseError json_err;
QJsonDocument json = QJsonDocument::fromJson(feed_contents, &json_err);
if (json.isNull() && !json_err.errorString().isEmpty()) {
throw ApplicationException(tr("JSON error '%1'").arg(json_err.errorString()));
}
feed->setTitle(json.object()[QSL("title")].toString());
feed->setDescription(json.object()[QSL("description")].toString());