The-Witcher-3-Mod-manager
The-Witcher-3-Mod-manager copied to clipboard
Already existing keys inside of mods.settings causes crash
If you use a modlist or happen to have a mod already in that file when the program reads the file, it will do one of two things: Either wipe the file entirely, giving an error that the key already exists, or if you try launching the program, it will crash with the same error.
I am assuming this is due to not handling this situation when you read the file. I have pasted what I think might be a solution to this issue, though it is not complete.
def readPriority(self):
self.priority.clear()
file = os.path.join(self.__userSettingsPath, '/mods.settings')
try:
########################################
############## Changes #################
########################################
# encoding is always utf-8
# specifying the 'r' arguement prevents the program from wiping a file when it encounters an error, as its only permitted to read
# Further improvements can be made if you do a if statement looking to see if the mods priority already exists.
# Example for the above:
# priority = deepcopy(self.priority)
# if i in priority: << i would be the index of the priority list, you would want to compare the expected list with the actual list
# pass <<< This is where you would want to read the priority that already exists
# self.priority.read(file, encoding=detectEncoding(file))
self.priority.read(file, 'r', encoding="utf-8")
except Exception as e:
MessageAlertReadingConfigINI(file, e)