From 0327eecf5ace2d35bca00f507d6942aa576cd584 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 14 Jun 2026 03:18:33 -0400 Subject: [PATCH] Only save region_map_sections.json when relevant changes are made --- include/project.h | 2 +- src/project.cpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/project.h b/include/project.h index 716046ea..2be41f94 100644 --- a/include/project.h +++ b/include/project.h @@ -323,8 +323,8 @@ private: QStringList groupNames; QMap groupNameToMapNames; - bool hasUnsavedDataChanges = false; bool hasUnsavedMapGroupChanges = false; + bool hasUnsavedMapsecChanges = false; struct EventGraphics { diff --git a/src/project.cpp b/src/project.cpp index a6430eac..239bfdd5 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -960,6 +960,8 @@ bool Project::saveMapGroups() { } bool Project::saveRegionMapSections() { + if (!this->hasUnsavedMapsecChanges) return true; + const QString filepath = QString("%1/%2").arg(this->root).arg(projectConfig.getFilePath(ProjectFilePath::json_region_map_entries)); QFile file(filepath); if (!file.open(QIODevice::WriteOnly)) { @@ -1000,6 +1002,8 @@ bool Project::saveRegionMapSections() { OrderedJsonDoc jsonDoc(&json); jsonDoc.dump(&file); file.close(); + + this->hasUnsavedMapsecChanges = false; return true; } @@ -1496,11 +1500,7 @@ bool Project::saveGlobalData() { if (!saveHealLocations()) success = false; if (!saveWildMonData()) success = false; if (!saveConfig()) success = false; - if (!success) - return false; - - this->hasUnsavedDataChanges = false; - return true; + return success; } bool Project::saveConfig() { @@ -2644,6 +2644,7 @@ void Project::setRegionMapEntries(const QHash &entries for (auto it = this->locationData.keyBegin(); it != this->locationData.keyEnd(); it++) { this->locationData[*it].map = entries.value(*it); } + this->hasUnsavedMapsecChanges = true; } QHash Project::getRegionMapEntries() const { @@ -2688,7 +2689,7 @@ bool Project::addNewMapsec(const QString &idName, const QString &displayName) { this->mapSectionIdNames.append(idName); Util::numericalModeSort(this->mapSectionIdNames); - this->hasUnsavedDataChanges = true; + this->hasUnsavedMapsecChanges = true; emit mapSectionAdded(idName); emit mapSectionIdNamesChanged(this->mapSectionIdNames); @@ -2702,7 +2703,7 @@ void Project::removeMapsec(const QString &idName) { this->mapSectionIdNames.removeOne(idName); this->mapSectionIdNamesSaveOrder.removeOne(idName); - this->hasUnsavedDataChanges = true; + this->hasUnsavedMapsecChanges = true; emit mapSectionIdNamesChanged(this->mapSectionIdNames); } @@ -2710,7 +2711,7 @@ void Project::setMapsecDisplayName(const QString &idName, const QString &display if (getMapsecDisplayName(idName) == displayName) return; this->locationData[idName].displayName = displayName; - this->hasUnsavedDataChanges = true; + this->hasUnsavedMapsecChanges = true; emit mapSectionDisplayNameChanged(idName, displayName); } @@ -3562,7 +3563,7 @@ void Project::applyParsedLimits() { } bool Project::hasUnsavedChanges() { - if (this->hasUnsavedDataChanges || this->hasUnsavedMapGroupChanges) + if (this->hasUnsavedMapsecChanges || this->hasUnsavedMapGroupChanges) return true; // Check layouts for unsaved changes