Skip to content

File selection cancel logic added#1040

Merged
carsen-stringer merged 1 commit intoMouseLand:mainfrom
knowblesse:main
Feb 11, 2025
Merged

File selection cancel logic added#1040
carsen-stringer merged 1 commit intoMouseLand:mainfrom
knowblesse:main

Conversation

@knowblesse
Copy link
Copy Markdown
Contributor

In current version, 9398cac, the gui.io module uses qtpy.QtWidgets.QFileDialog to prompt the user for an input image.

name = QFileDialog.getOpenFileName(parent, "Load image")

However, if the user cancels the file selection, QFileDialog returns an empty string, which is then passed to imread at line 125.

cellpose/cellpose/gui/io.py

Lines 125 to 126 in 9398cac

image = imread(filename)
parent.loaded = True

Since imread has its own error handling, all exceptions are suppressed, and line 126 (parent.loaded = True) is executed even if no file is selected.

This behavior is undesired, so a simple filename check has been added to return from the _load_image function without setting parent.loaded to True if no file is selected.

@knowblesse
Copy link
Copy Markdown
Contributor Author

It's just a minor error, but since parent.loaded is used widely throughout the code, it might cause unexpected behavior in other cases.

@carsen-stringer
Copy link
Copy Markdown
Member

thanks!

@carsen-stringer carsen-stringer merged commit d557093 into MouseLand:main Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants