Skip to content

Commit

Permalink
Prevent multiple on exit prompts on gnome
Browse files Browse the repository at this point in the history
  • Loading branch information
ObaraEmmanuel committed Apr 18, 2022
1 parent fe64646 commit 022effe
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions studio/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def __init__(self, master=None, **cnf):
self._startup()
self._restore_position()
self._exit_failures = 0
self._is_shutting_down = False

def _startup(self):
on_startup = pref.get("studio::on_startup")
Expand Down Expand Up @@ -590,15 +591,21 @@ def _force_exit_prompt(self):

def _on_close(self):
""" Return ``True`` if exit successful otherwise ``False`` """
if self._is_shutting_down:
# block multiple close attempts
return
self._is_shutting_down = True
try:
self._save_position()
# pass the on window close event to the features
for feature in self._all_features():
# if any feature returns false abort shut down
feature.save_window_pos()
if not feature.on_app_close():
self._is_shutting_down = False
return False
if not self.tool_manager.on_app_close():
self._is_shutting_down = False
return False
self.quit()
return True
Expand All @@ -609,6 +616,7 @@ def _on_close(self):
if force:
# exit by all means necessary
sys.exit(1)
self._is_shutting_down = False
return False

def get_help(self):
Expand Down

0 comments on commit 022effe

Please sign in to comment.