diff options
| author | Tannin <devnull@localhost> | 2013-09-28 21:13:57 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-09-28 21:13:57 +0200 |
| commit | 47293827bbd92ce227e5188c10b66deb9f85d5bf (patch) | |
| tree | c8e9f34dc3105a3e73b41f8b2fb58d58439b06e0 /src/modinfo.cpp | |
| parent | 0a3169b808cf2b84ae7c77fd6cb0a7b0aa9a8df3 (diff) | |
- download progress is now visible in task bar
- esp-tooltip now lists all masters, highlighting the missing ones
- python plugin will now report a problem if the path contains a semicolon
- leak detection now (somewaht) works around the fact that we don't always get a stack trace
- bugfix: mod meta-file is now reliably created if it was missing
- bugfix: parser for nxm-links didn't handle numbers in the mod name
- bugfix: small memory leak
Diffstat (limited to 'src/modinfo.cpp')
| -rw-r--r-- | src/modinfo.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 166c815b..7632a86e 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -350,8 +350,6 @@ ModInfoRegular::ModInfoRegular(const QDir &path, DirectoryEntry **directoryStruc ModInfoRegular::~ModInfoRegular() { try { - //TODO this may cause the meta-file and the directory to be - // re-created after a remove saveMeta(); } catch (const std::exception &e) { qCritical("failed to save meta information for \"%s\": %s", @@ -371,28 +369,25 @@ bool ModInfoRegular::isEmpty() const void ModInfoRegular::saveMeta() { - if (m_MetaInfoChanged) { - if (QFile::exists(absolutePath().append("/meta.ini"))) { - QSettings metaFile(absolutePath().append("/meta.ini"), QSettings::IniFormat); - if (metaFile.status() == QSettings::NoError) { - std::set<int> temp = m_Categories; - temp.erase(m_PrimaryCategory); - metaFile.setValue("category", QString("%1").arg(m_PrimaryCategory) + "," + SetJoin(temp, ",")); - metaFile.setValue("newestVersion", m_NewestVersion.canonicalString()); - metaFile.setValue("version", m_Version.canonicalString()); - metaFile.setValue("modid", m_NexusID); - metaFile.setValue("notes", m_Notes); - metaFile.setValue("nexusDescription", m_NexusDescription); - metaFile.setValue("lastNexusQuery", m_LastNexusQuery.toString(Qt::ISODate)); - if (m_EndorsedState != ENDORSED_UNKNOWN) { - metaFile.setValue("endorsed", m_EndorsedState); - } - - } else { - reportError(tr("failed to write %1/meta.ini: %2").arg(absolutePath()).arg(metaFile.status())); + // only write meta data if the mod directory exists + if (m_MetaInfoChanged && QFile::exists(absolutePath())) { + QSettings metaFile(absolutePath().append("/meta.ini"), QSettings::IniFormat); + if (metaFile.status() == QSettings::NoError) { + std::set<int> temp = m_Categories; + temp.erase(m_PrimaryCategory); + metaFile.setValue("category", QString("%1").arg(m_PrimaryCategory) + "," + SetJoin(temp, ",")); + metaFile.setValue("newestVersion", m_NewestVersion.canonicalString()); + metaFile.setValue("version", m_Version.canonicalString()); + metaFile.setValue("modid", m_NexusID); + metaFile.setValue("notes", m_Notes); + metaFile.setValue("nexusDescription", m_NexusDescription); + metaFile.setValue("lastNexusQuery", m_LastNexusQuery.toString(Qt::ISODate)); + if (m_EndorsedState != ENDORSED_UNKNOWN) { + metaFile.setValue("endorsed", m_EndorsedState); } + metaFile.sync(); // sync needs to be called to ensure the file is created } else { - qWarning("mod %s has no meta.ini at %s/meta.ini", m_Name.toUtf8().constData(), absolutePath().toUtf8().constData()); + reportError(tr("failed to write %1/meta.ini: %2").arg(absolutePath()).arg(metaFile.status())); } m_MetaInfoChanged = false; } |
