-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Don't start separate event loop for QFileDialog #16158
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for discussion (not a hard blocker):
Formally speaking this is the wrong approach (and this problem plague all GUI code). Is there a better way of solving it?
I suppose it can record a list of infohash instead and resolve it to torrent handle later when needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can have TorrentPtr like QPointer, which automatically becomes null when the torrent is removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The real wrong case is passing
QModelIndex
(orTorrent *
) list to asynchronous handler (since they can be invalidated in between).I don't do this here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is good, but how would the implementation look like? or is it even feasible?
The invalidated entries will be discarded while the rest (valid) entries will still apply the action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you misunderstood me.
If you store pointers you can't know which of them are invalid. So you should either store Torrent IDs and then try to obtain corresponding torrents or store QPointers and check them for
nullptr
. Or obtain selected items in handler (as I'm done).Make Torrent to inherit QObject and store QPointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is why I said storing the infohash instead.
That probably will do.
AFAIK it might be possible that before the asynchronous handler took action the user reselected the torrents, even the timing window is very small this way (obtaining selected items in handler) is still wrong IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if the user has time to click something at this time (during executing of discussed handler), this event (selecting/deselecting torrents) will be processed only after processing the current one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, the handler is connected to
QDialog::accepted
and a lot of things can happen before the signal is triggered...Although the dialog is made
modal
so users cannot really reselect torrents but I still don't consider this code robust as it isn't a general pattern for all dialogs (including non-modal ones).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handlers (slots) are called directly unless "queued connection" is used.
Yes, it is.
When you create some dialog that should affect some selection from other place non-modal so your intention is allowing the user to reconsider selection and apply dialog action to the final one (otherwise making dialog non-modal is meaningless/confusing). So it seems to be general pattern for all dialogs affecting some selection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant (generally speaking) a lot of UI events, background automatic processing, etc. could happen.
It would be correct only if the dialog says you can reselect the entries, which is not the case for most actions. This idea is not implied by dialogs (by default), which would be counter-intuitive.
Making dialog non-modal has other meanings, not just limited to this one.