Skip to content

Commit

Permalink
Merge from 5.x: PR #17732
Browse files Browse the repository at this point in the history
Fixes #17729
  • Loading branch information
ccordoba12 committed Apr 23, 2022
2 parents 1f085b5 + 1c9aca5 commit 158669e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/installer-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
run: ${pythonLocation}/bin/python setup.py ${LITE_FLAG} --dist-dir ${DISTDIR}
- name: Test Application Bundle
if: ${{github.event_name == 'pull_request'}}
run: ./test_app.sh -t 60 ${DISTDIR}
run: ./test_app.sh -t 60 -d 10 ${DISTDIR}
- name: Build Disk Image
run: ${pythonLocation}/bin/python setup.py ${LITE_FLAG} --dist-dir ${DISTDIR} --dmg --no-app
- name: Upload Artifact
Expand Down
2 changes: 2 additions & 0 deletions installers/macOS/req-extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ pyflakes
pyxdg
rope
yapf
# Temporarily limit jupyter-client spyder-ide/spyder#17615
jupyter-client<7.2.1
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 158669e

Please sign in to comment.