Skip to content

Commit

Permalink
Only show one prompt on model reload
Browse files Browse the repository at this point in the history
  • Loading branch information
s-simoncelli committed Feb 17, 2024
1 parent 940814d commit 9f0bd8d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pywr_editor/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def __init__(self, model_file: str | None = None):
)
sys.exit(1)
self.empty_model: bool = False
self.prompt_unsaved_changes: bool = True
""" Prompts the user for unsaved model changes """

if model_file is None:
self.logger.debug("No model file was provided")
Expand Down Expand Up @@ -755,6 +757,9 @@ def maybe_save(self) -> bool:
Asks user if they want to save the model file before exiting the editor.
:return: True whether the close the window, False otherwise.
"""
if not self.prompt_unsaved_changes:
return True

message = QMessageBox(self)
message.setWindowTitle("Unsaved changes")
message.setIcon(QMessageBox.Icon.Information)
Expand Down Expand Up @@ -1084,5 +1089,6 @@ def reload_model_file(self) -> None:

answer = message.exec()
if answer == QMessageBox.StandardButton.Ok:
self.prompt_unsaved_changes = False
MainWindow(self.model_file)
self.close()

0 comments on commit 9f0bd8d

Please sign in to comment.