Skip to content

Commit

Permalink
Library scan: don't show summary when run during startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jul 29, 2024
1 parent db2e6fa commit 1cd81d7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/coreservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ void CoreServices::initialize(QApplication* pApp) {
// Scan the library directory. Do this after the skinloader has
// loaded a skin, see issue #6625
if (rescan || musicDirAdded || m_pSettingsManager->shouldRescanLibrary()) {
m_pTrackCollectionManager->startLibraryScan();
m_pTrackCollectionManager->startLibraryScanNoReport();
}

// This has to be done before m_pSoundManager->setupDevices()
Expand Down
14 changes: 8 additions & 6 deletions src/library/scanner/libraryscanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ LibraryScanner::LibraryScanner(
const UserSettingsPointer& pConfig)
: m_pDbConnectionPool(std::move(pDbConnectionPool)),
m_analysisDao(pConfig),
m_trackDao(m_cueDao, m_playlistDao,
m_analysisDao, m_libraryHashDao,
pConfig),
m_trackDao(m_cueDao, m_playlistDao, m_analysisDao, m_libraryHashDao, pConfig),
m_stateSema(1), // only one transaction is possible at a time
m_state(IDLE) {
m_state(IDLE),
m_emitSummaryReport(true) {
// Move LibraryScanner to its own thread so that our signals/slots will
// queue to our event loop.
moveToThread(this);
Expand Down Expand Up @@ -461,11 +460,14 @@ void LibraryScanner::slotFinishUnhashedScan() {
// now we may accept new scan commands

emit scanFinished();
emit scanSummary(result);
if (m_emitSummaryReport) {
emit scanSummary(result);
}
}

void LibraryScanner::scan() {
void LibraryScanner::scan(bool requestSummaryReport) {
if (changeScannerState(STARTING)) {
m_emitSummaryReport = requestSummaryReport;
emit startScan();
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/library/scanner/libraryscanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class LibraryScanner : public QThread {
public slots:
// Call from any thread to start a scan. Does nothing if a scan is already
// in progress.
void scan();
// Optionally omit summary report. Purpose is to not show the summary dialog
// during startup when being called by CoreServices::initialize.
void scan(bool requestSummaryReport = true);

// Call from any thread to cancel the scan.
void slotCancel();
Expand Down Expand Up @@ -125,4 +127,6 @@ class LibraryScanner : public QThread {

QList<mixxx::FileInfo> m_libraryRootDirs;
QScopedPointer<LibraryScannerDlg> m_pProgressDlg;

bool m_emitSummaryReport;
};
7 changes: 7 additions & 0 deletions src/library/trackcollectionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ TrackCollectionManager::~TrackCollectionManager() {
GlobalTrackCache::destroyInstance();
}

void TrackCollectionManager::startLibraryScanNoReport() {
VERIFY_OR_DEBUG_ASSERT(m_pScanner) {
return;
}
m_pScanner->scan(false);
}

void TrackCollectionManager::startLibraryScan() {
VERIFY_OR_DEBUG_ASSERT(m_pScanner) {
return;
Expand Down
2 changes: 2 additions & 0 deletions src/library/trackcollectionmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class TrackCollectionManager: public QObject,
Failed,
};
SaveTrackResult saveTrack(const TrackPointer& pTrack) const;
// Same as startLibraryScan() but don't emit the scan summary.
void startLibraryScanNoReport();

signals:
void libraryScanStarted();
Expand Down

0 comments on commit 1cd81d7

Please sign in to comment.