Skip to content
Snippets Groups Projects
Commit 31f95c4b authored by Martin Högstedt's avatar Martin Högstedt
Browse files

Merge branch '51-tell-user-if-saving-goes-wrong' into 'main'

Tell user if unable/able to save

Closes #51

See merge request !25
parents e6845316 beda43b0
No related branches found
No related tags found
1 merge request!25Tell user if unable/able to save
Pipeline #132178 passed
from __future__ import annotations
from os import error
from simudator.core.signal import Signal
......
......@@ -497,7 +497,7 @@ class Processor:
module = self.get_module(module_name)
module.load_from_str(module_str)
def save_state_to_file(self, file_path: str) -> None:
def save_state_to_file(self, file_path: str) -> bool:
"""Save the current state of the cpu to file.
Will overwrite the given file.
......@@ -512,7 +512,12 @@ class Processor:
file.close()
for module in self.modules.values():
module.save_state_to_file(file_path)
res =module.save_state_to_file(file_path)
if not res:
return False
return True
def pretty_print(self) -> None:
"""Print the processor state in a readable and compact format."""
......
......@@ -848,7 +848,12 @@ class GUI(QMainWindow):
if path == '':
return
self.cpu.save_state_to_file(path)
res = self.cpu.save_state_to_file(path)
if res:
self.messageBox("File saved.")
else:
self.errorBox("Unable to save.")
def openBreakpointWindow(self) -> None:
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment