[Downloads] Use a queued connection for the download manager everywhere #1076
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.
Fix #1073
I previously assumed that we had a threading issue. But this is not
the case because connect() calls methods of DownloadManager only in one
thread, DownloadManager's thread.
But I forgot that signals (e.g. "emit sigFinished") call their slots
immediately by default. This means we could end up in inconsistent
states because member variables are changed while we are still inside a
method that depends on them or has a previous state. For example:
To avoid this, I've adapted all places where a connect() to this
download manager is used. Those places now all used a queued
connection.
But to be more robust, we should refactor this class and get rid of
all member variables that may change state.
Also, this would allow parallel downloads.