Ver código fonte

- made sure that the Preferences files are deleted on new version install, while the application is in Beta status

Marius Stanciu 5 anos atrás
pai
commit
676645d6f5
3 arquivos alterados com 11 adições e 3 exclusões
  1. 1 0
      CHANGELOG.md
  2. 1 1
      app_Main.py
  3. 9 2
      defaults.py

+ 1 - 0
CHANGELOG.md

@@ -17,6 +17,7 @@ CHANGELOG for FlatCAM beta
 - Excellon UI: fixed plot checkbox performing an extra plot function which was not required
 - Excellon UI: added a column which will color each row/tool of that column in the color used when checking Multicolor checkbox
 - Excellon UI: made sure that when the Multicolor checkbox is unchecked, the color is updated in the Color column of the tools table
+- made sure that the Preferences files are deleted on new version install, while the application is in Beta status
 
 20.07.2020
 

+ 1 - 1
app_Main.py

@@ -420,7 +420,7 @@ class App(QtCore.QObject):
         # ############################################################################################################
         # ################################# DEFAULTS - PREFERENCES STORAGE ###########################################
         # ############################################################################################################
-        self.defaults = FlatCAMDefaults()
+        self.defaults = FlatCAMDefaults(beta=self.beta)
 
         self.defaults["root_folder_path"] = self.app_home
 

+ 9 - 2
defaults.py

@@ -770,7 +770,7 @@ class FlatCAMDefaults:
         except Exception as e:
             log.error("save_factory_defaults() -> %s" % str(e))
 
-    def __init__(self, callback=lambda x: None):
+    def __init__(self, callback=lambda x: None, beta=True):
         """
 
         :param callback:    A method called each time that one of the values are changed in the self.defaults LouDict
@@ -781,6 +781,7 @@ class FlatCAMDefaults:
         self.current_defaults.update(self.factory_defaults)
         self.old_defaults_found = False
 
+        self.beta = beta
         self.defaults.set_change_callback(callback)
 
     # #### Pass-through to the defaults LoudDict #####
@@ -840,7 +841,13 @@ class FlatCAMDefaults:
         # Perform migration if necessary but only if the defaults dict is not empty
         if self.__is_old_defaults(defaults) and defaults:
             self.old_defaults_found = True
-            defaults = self.__migrate_old_defaults(defaults=defaults)
+
+            # while the app is in Beta status, delete the older Preferences files
+            if self.beta is False:
+                defaults = self.__migrate_old_defaults(defaults=defaults)
+            else:
+                # wipeout the old defaults
+                self.reset_to_factory_defaults(defaults=defaults)
         else:
             self.old_defaults_found = False