Skip to content

Commit

Permalink
AutoDJ: fix GUI freeze when updating duration of many selected tracks
Browse files Browse the repository at this point in the history
* move the duration collection to TrackDAO
* query the database duration column instead of inspecting each Track object
  • Loading branch information
ronso0 committed Jan 7, 2024
1 parent af5ca37 commit 2eb9e24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/library/autodj/dlgautodj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ DlgAutoDJ::DlgAutoDJ(WLibrary* parent,
: QWidget(parent),
Ui::DlgAutoDJ(),
m_pConfig(pConfig),
m_pLibrary(pLibrary),
m_pAutoDJProcessor(pProcessor),
m_pTrackTableView(new WTrackTableView(this,
m_pConfig,
Expand Down Expand Up @@ -367,12 +368,14 @@ void DlgAutoDJ::updateSelectionInfo() {

QModelIndexList indices = m_pTrackTableView->selectionModel()->selectedRows();

QList<TrackId> ids;
for (int i = 0; i < indices.size(); ++i) {
TrackPointer pTrack = m_pAutoDJTableModel->getTrack(indices.at(i));
if (pTrack) {
duration += pTrack->getDuration();
}
ids.append(m_pAutoDJTableModel->getTrackId(indices.at(i)));
}
TrackDAO* pTrackDAO = &(m_pLibrary->trackCollectionManager()
->internalCollection()

Check failure on line 376 in src/library/autodj/dlgautodj.cpp

View workflow job for this annotation

GitHub Actions / clazy

member access into incomplete type 'TrackCollectionManager'

Check failure on line 376 in src/library/autodj/dlgautodj.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 (gcc)

invalid use of incomplete type ‘class TrackCollectionManager’

Check failure on line 376 in src/library/autodj/dlgautodj.cpp

View workflow job for this annotation

GitHub Actions / clang-tidy

member access into incomplete type 'TrackCollectionManager' [clang-diagnostic-error]

Check failure on line 376 in src/library/autodj/dlgautodj.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 (Qt 6.2, gcc)

invalid use of incomplete type ‘class TrackCollectionManager’

Check failure on line 376 in src/library/autodj/dlgautodj.cpp

View workflow job for this annotation

GitHub Actions / coverage

invalid use of incomplete type ‘class TrackCollectionManager’

Check failure on line 376 in src/library/autodj/dlgautodj.cpp

View workflow job for this annotation

GitHub Actions / Windows 2019 (MSVC)

use of undefined type 'TrackCollectionManager'
->getTrackDAO());
duration = pTrackDAO->getTrackDurationsTotal(ids);

QString label;

Expand Down
1 change: 1 addition & 0 deletions src/library/autodj/dlgautodj.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class DlgAutoDJ : public QWidget, public Ui::DlgAutoDJ, public LibraryView {
void keyPressEvent(QKeyEvent* pEvent) override;

const UserSettingsPointer m_pConfig;
Library* const m_pLibrary;

AutoDJProcessor* const m_pAutoDJProcessor;
WTrackTableView* const m_pTrackTableView;
Expand Down

0 comments on commit 2eb9e24

Please sign in to comment.