diff options
Diffstat (limited to 'src/loot.cpp')
| -rw-r--r-- | src/loot.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/loot.cpp b/src/loot.cpp index a888b577..6159521b 100644 --- a/src/loot.cpp +++ b/src/loot.cpp @@ -732,6 +732,7 @@ void Loot::processReport(Report& r) const QJsonParseError e; const QJsonDocument doc = QJsonDocument::fromJson(reportFile.readAll(), &e); + reportFile.close(); if (doc.isNull()) { emit log(MOBase::log::Error, QString("invalid json, %1 (error %2)").arg(e.errorString()).arg(e.error)); @@ -776,22 +777,27 @@ const QString Loot::getSortedPluginListMarkdown() const log::debug("parsing sorted plugin list at '{}'", SortedPluginListPath); QFile pluginListFile(SortedPluginListPath); - if (!pluginListFile.open(QIODevice::ReadOnly)) { + if (!pluginListFile.open(QIODevice::ReadOnly | QIODevice::Text)) { emit log(MOBase::log::Error, QString("failed to open file, %1 (error %2)") .arg(pluginListFile.errorString()) .arg(pluginListFile.error())); return {}; } - // skip "# This file was automatically generated by Mod Organizer" - pluginListFile.readLine(); - QString markdown = "### " + tr("Sorted plugins") + "\n<details><summary>" + tr("Show") + "</summary>\n\n"; - const auto pluginList = m_core.pluginList(); - while (!pluginListFile.atEnd()) { - const QString pluginName = QString::fromUtf8(pluginListFile.readLine().trimmed()); + const auto pluginList = m_core.pluginList(); + const QByteArray contents = pluginListFile.readAll(); + pluginListFile.close(); + + for (const QString& line : + QString::fromUtf8(contents).split('\n', Qt::SkipEmptyParts)) { + if (line.at(0) == '#') { + continue; + } + + const QString pluginName = line.trimmed(); const bool active = pluginList->isEnabled(pluginName); const QString prefix = active ? " - [x] " : " - [ ] "; markdown += prefix + pluginName + "\n"; @@ -799,7 +805,6 @@ const QString Loot::getSortedPluginListMarkdown() const markdown += "</details>\n"; - pluginListFile.close(); return markdown; } |
