Open melissawm opened 3 hours ago
Great catch @melissawm and good suggestion.
Looking at the traceback it seems as if there is a message created but it's not displayed to the user and sent to error handling.
File ~/Code/repos-napari/napari/napari/_qt/qt_viewer.py:756, in QtViewer._save_layers_dialog(self=<napari._qt.qt_viewer.QtViewer object>, selected=True)
751 msg = trans._(
752 'Please select one or more layers to save,'
753 '\nor use "Save all layers..."'
754 )
755 if msg:
--> 756 raise OSError(trans._('Nothing to save'))
Interesting, on macOS if I have no layer selected, the menu item is greyed-out and Command-S does nothing: no error, no warning. Odd that it behaves differently with different OS. @lucyleeow any ideas?
I was able to reproduce on macOS sequoia when using the keyboard shortcut (on main not released version)
π Bug Report
When using Ctrl+S (on Linux) to try to save a layer with no layer selected through the GUI, an OSError appears which is not very friendly to users.
π‘ Steps to Reproduce
π‘ Expected Behavior
Maybe a dialog with a friendlier "No layer selected. Please select a layer to save" message.
π Environment
napari dev Manjaro Linux + KDE Python 3.11
π‘ Additional Context
Full traceback
``` --------------------------------------------------------------------------- OSError Traceback (most recent call last) File ~/micromamba/envs/napari-dev/lib/python3.11/site-packages/app_model/backends/qt/_qaction.py:57, in QCommandAction._on_triggered(self=QMenuItemAction(MenuItem(when=None, group='4_sav...tle=None, toggled=None), alt=None), app='napari'), checked=False) 53 def _on_triggered(self, checked: bool) -> None: 54 # execute_command returns a Future, for the sake of eventually being 55 # asynchronous without breaking the API. For now, we call result() 56 # to raise any exceptions. ---> 57 self._app.commands.execute_command(self._command_id).result() self._command_id = 'napari.window.file.save_layers_dialog.selected' self = QMenuItemAction(MenuItem(when=None, group='4_save', order=None, command=CommandRule(id='napari.window.file.save_layers_dialog.selected', title='Save Selected Layers...', category=None, tooltip=None, status_tip=None, icon=None, icon_visible_in_menu=True, enablement=Expr.parse('num_selected_layers > 0'), short_title=None, toggled=None), alt=None), app='napari') self._app = Application('napari') File ~/micromamba/envs/napari-dev/lib/python3.11/site-packages/app_model/registries/_commands_reg.py:245, in CommandsRegistry.execute_command(self=