From 1cd81d7231d2a1e37ff94498d76028f382b35e89 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Thu, 25 Jul 2024 18:04:35 +0200 Subject: [PATCH] Library scan: don't show summary when run during startup --- src/coreservices.cpp | 2 +- src/library/scanner/libraryscanner.cpp | 14 ++++++++------ src/library/scanner/libraryscanner.h | 6 +++++- src/library/trackcollectionmanager.cpp | 7 +++++++ src/library/trackcollectionmanager.h | 2 ++ 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/coreservices.cpp b/src/coreservices.cpp index b0c707f10b0..d7d08299321 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -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() diff --git a/src/library/scanner/libraryscanner.cpp b/src/library/scanner/libraryscanner.cpp index 46a1af530a2..839021f34db 100644 --- a/src/library/scanner/libraryscanner.cpp +++ b/src/library/scanner/libraryscanner.cpp @@ -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); @@ -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(); } } diff --git a/src/library/scanner/libraryscanner.h b/src/library/scanner/libraryscanner.h index bc1d022785e..6c22b6ad307 100644 --- a/src/library/scanner/libraryscanner.h +++ b/src/library/scanner/libraryscanner.h @@ -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(); @@ -125,4 +127,6 @@ class LibraryScanner : public QThread { QList m_libraryRootDirs; QScopedPointer m_pProgressDlg; + + bool m_emitSummaryReport; }; diff --git a/src/library/trackcollectionmanager.cpp b/src/library/trackcollectionmanager.cpp index d67652b7593..5aa5ecafecb 100644 --- a/src/library/trackcollectionmanager.cpp +++ b/src/library/trackcollectionmanager.cpp @@ -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; diff --git a/src/library/trackcollectionmanager.h b/src/library/trackcollectionmanager.h index 56f91c92b89..674c3bff9dc 100644 --- a/src/library/trackcollectionmanager.h +++ b/src/library/trackcollectionmanager.h @@ -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();