Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File selection cancel logic added #1040

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

knowblesse
Copy link

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
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.

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.

1 participant