1
0

wizard: copy/restore storage when stepping through the wizard

When interacting with wizard, there is a single shared storage instance.
If you go down the tree of dialogs, press "back" a couple times, go
down another branch of dialogs, etc, there are side-effects on storage,
which are never undone.

fixes #5057
fixes #4496
This commit is contained in:
SomberNight
2019-02-04 17:07:49 +01:00
parent 9013f6d59e
commit 8412b53ed5
2 changed files with 34 additions and 7 deletions

View File

@@ -101,6 +101,20 @@ class JsonDB(PrintError):
self.modified = True
self.data.pop(key)
def get_all_data(self) -> dict:
with self.db_lock:
return copy.deepcopy(self.data)
def overwrite_all_data(self, data: dict) -> None:
try:
json.dumps(data, cls=util.MyEncoder)
except:
self.print_error(f"json error: cannot save {repr(data)}")
return
with self.db_lock:
self.modified = True
self.data = copy.deepcopy(data)
@profiler
def write(self):
with self.db_lock: