-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
AutoDJ: fix GUI freeze when updating duration for many selected tracks #12530
Conversation
@uklotzde Do you have time to take a look? |
Hmm, no, this should better be a helper in PlaylistTableModel |
Yes, and that's also much faster: ~5ms vs. 28ms for 16k tracks (maybe because no QHash and no second iteration?) edit SELECT
SUM(library.duration)
FROM PlaylistTracks
LEFT JOIN library
ON PlaylistTracks.track_id = library.id
AND PlaylistTracks.playlist_id = playlistId
AND PlaylistTracks.position IN (selectedPositions) |
2eb9e24
to
32d17d9
Compare
@@ -319,6 +319,22 @@ void PlaylistTableModel::shuffleTracks(const QModelIndexList& shuffle, const QMo | |||
m_pTrackCollectionManager->internalCollection()->getPlaylistDAO().shuffleTracks(m_iPlaylistId, positions, allIds); | |||
} | |||
|
|||
double PlaylistTableModel::getDurationOfRows(const QModelIndexList& indices) { |
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.
can you add a short explanatory comment, like:
// Derive total duration from the display widget instead of the database to speed up calculation.
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'll add that in DlgAutoDJ where it is called, no need to mention that here IMO
32d17d9
to
9cd0dce
Compare
src/library/playlisttablemodel.cpp
Outdated
} | ||
|
||
const int durationColumnIndex = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_DURATION); | ||
for (const auto index : indices) { |
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.
for (const auto index : indices) { | |
for (const auto& index : indices) { |
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 on missing &
9cd0dce
to
c08607a
Compare
Done. |
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.
LGTM, thank you
Oh, I just pushed the changes suggested by @uklotzde (it was a comment not a formal change request). The update is #12537 |
fixes #12520
move the duration collection to TrackDAOquery the database duration column instead of inspecting each Track object(could also be in any of the classes that is derived from but... YAGNI?)
Now updating the info for ~16k tracks takes ~5ms here.
With the 2.4 code, updating the info for 3 tracks already takes ~40ms 😬