Skip to content

Commit

Permalink
Remove macOS app case in closing window.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrclary committed Apr 22, 2022
1 parent 6912b9a commit e29c0d9
Showing 1 changed file with 26 additions and 58 deletions.
84 changes: 26 additions & 58 deletions spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ def post_visible_setup(self):
# when it gets a client connected to it
self.sig_open_external_file.connect(self.open_external_file)


# Update plugins toggle actions to show the "Switch to" plugin shortcut
self._update_shortcuts_in_panes_menu()

Expand Down Expand Up @@ -1499,68 +1499,36 @@ def closing(self, cancelable=False, close_immediately=False):
if reply == QMessageBox.No:
return False

# TODO: This should be managed in a different way
# Prevents segfaults on close in the MacOS app
if running_in_mac_app():
# Close Editor and projects to run logic to save state:
# Open files/project, check unsaved files, etc.
if self.editor is not None:
try:
self.editor.deleteLater()
self.plugin_registry.delete_plugin(
Plugins.Editor, teardown=False)
except RuntimeError:
pass
if self.projects is not None:
try:
self.projects.get_widget().close()
self.projects.get_widget().deleteLater()
self.plugin_registry.delete_plugin(
Plugins.Projects, teardown=False)
except RuntimeError:
pass
# Save window settings *after* closing all plugin windows, in order
# to show them in their previous locations in the next session.
# Fixes spyder-ide/spyder#12139
prefix = 'window' + '/'
if self.layouts is not None:
self.layouts.save_current_window_settings(prefix)

# Close application
os._exit(0)
app = qapplication() # analysis:ignore
del app
else:
can_close = self.plugin_registry.delete_all_plugins(
excluding={Plugins.Layout},
close_immediately=close_immediately)
can_close = self.plugin_registry.delete_all_plugins(
excluding={Plugins.Layout},
close_immediately=close_immediately)

if not can_close and not close_immediately:
return False
if not can_close and not close_immediately:
return False

# Save window settings *after* closing all plugin windows, in order
# to show them in their previous locations in the next session.
# Fixes spyder-ide/spyder#12139
prefix = 'window' + '/'
if self.layouts is not None:
self.layouts.save_current_window_settings(prefix)
try:
layouts_container = self.layouts.get_container()
if layouts_container:
layouts_container.close()
layouts_container.deleteLater()
self.layouts.deleteLater()
self.plugin_registry.delete_plugin(
Plugins.Layout, teardown=False)
except RuntimeError:
pass
# Save window settings *after* closing all plugin windows, in order
# to show them in their previous locations in the next session.
# Fixes spyder-ide/spyder#12139
prefix = 'window' + '/'
if self.layouts is not None:
self.layouts.save_current_window_settings(prefix)
try:
layouts_container = self.layouts.get_container()
if layouts_container:
layouts_container.close()
layouts_container.deleteLater()
self.layouts.deleteLater()
self.plugin_registry.delete_plugin(
Plugins.Layout, teardown=False)
except RuntimeError:
pass

self.already_closed = True
self.already_closed = True

if CONF.get('main', 'single_instance') and self.open_files_server:
self.open_files_server.close()
if CONF.get('main', 'single_instance') and self.open_files_server:
self.open_files_server.close()

QApplication.processEvents()
QApplication.processEvents()

return True

Expand Down

0 comments on commit e29c0d9

Please sign in to comment.