Deep copy the default_config constant to prevent it being overwritten

- Issue
  - In the previous form, updates to self.current_config would update
    default_config as python does a shallow copy
  - So self.current_config is just referencing the values of default_config
  - Hence updates to current_config updates the default_config values too
  - This is not what we want

- Fix
  - Deep copy the default_config values. Now updates to
    self.current_config wouldn't affect the default_config
This commit is contained in:
Debanjum Singh Solanky
2022-08-12 23:54:16 +03:00
parent 62ac41ce3b
commit 28a91ad1fd

View File

@@ -1,5 +1,7 @@
# Standard Packages
from pathlib import Path
from copy import deepcopy
# External Packages
from PyQt6 import QtWidgets
@@ -31,7 +33,7 @@ class ConfigureScreen(QtWidgets.QDialog):
if resolve_absolute_path(self.config_file).exists():
self.current_config = yaml_utils.load_config_from_file(self.config_file)
else:
self.current_config = constants.default_config
self.current_config = deepcopy(constants.default_config)
self.new_config = self.current_config
# Initialize Configure Window