From 28a91ad1fdcf0385885ed0103b41198e0a239357 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Fri, 12 Aug 2022 23:54:16 +0300 Subject: [PATCH] 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 --- src/interface/desktop/configure_screen.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/interface/desktop/configure_screen.py b/src/interface/desktop/configure_screen.py index 5f7ad86e..30f78bf2 100644 --- a/src/interface/desktop/configure_screen.py +++ b/src/interface/desktop/configure_screen.py @@ -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