From fed4ea257ab7ae7c154c4c4e3ac6ec8fd4093f59 Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Tue, 26 Dec 2017 19:07:55 +0200 Subject: Fix mods priorities getting messed up when renaming a mod --- src/modlist.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/modlist.cpp') diff --git a/src/modlist.cpp b/src/modlist.cpp index 046e2280..4002a424 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -426,13 +426,16 @@ bool ModList::renameMod(int index, const QString &newName) ModInfo::Ptr modInfo = ModInfo::getByIndex(index); QString oldName = modInfo->name(); - if (newName != oldName && modInfo->setName(nameFixed)) { - // before we rename, write back the current profile so we don't lose changes and to ensure - // there is no scheduled asynchronous rewrite anytime soon - m_Profile->writeModlistNow(); + if (newName != oldName) { + // before we rename, ensure there is no scheduled asynchronous to rewrite + m_Profile->cancelModlistWrite(); - // this just disabled the mod in all profiles. The recipient of modRenamed must fix that - emit modRenamed(oldName, nameFixed); + + if (modInfo->setName(nameFixed)) + // Notice there is a good chance that setName() updated the modinfo indexes + // the modRenamed() call will refresh the indexes in the current profile + // and update the modlists in all profiles + emit modRenamed(oldName, nameFixed); } // invalidate the currently displayed state of this list -- cgit v1.3.1