Skip to content

Commit

Permalink
Stop worker threads before exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde committed Dec 28, 2018
1 parent 78cef8f commit dcf6301
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/analyzer/trackanalysisscheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,11 @@ bool TrackAnalysisScheduler::submitNextTrack(Worker* worker) {

void TrackAnalysisScheduler::stop() {
kLogger.debug() << "Stopping";
m_queuedTrackIds.clear();
for (auto& worker: m_workers) {
worker.stopThread();
}
m_workers.clear();
}

TrackPointer TrackAnalysisScheduler::loadTrackById(TrackId trackId) {
Expand Down
7 changes: 4 additions & 3 deletions src/library/analysisfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ AnalysisFeature::AnalysisFeature(
setTitleDefault();
}

AnalysisFeature::~AnalysisFeature() {
// TODO(XXX) delete these
//delete m_pLibraryTableModel;
void AnalysisFeature::stop() {
if (m_pTrackAnalysisScheduler) {
m_pTrackAnalysisScheduler->stop();
}
}

void AnalysisFeature::setTitleDefault() {
Expand Down
4 changes: 3 additions & 1 deletion src/library/analysisfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class AnalysisFeature : public LibraryFeature {
public:
AnalysisFeature(Library* parent,
UserSettingsPointer pConfig);
virtual ~AnalysisFeature();
~AnalysisFeature() override = default;

void stop();

QVariant title();
QIcon getIcon();
Expand Down
8 changes: 8 additions & 0 deletions src/library/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ Library::~Library() {
delete m_pTrackCollection;
}

void Library::stopFeatures() {
if (m_pAnalysisFeature) {
m_pAnalysisFeature->stop();
m_pAnalysisFeature = nullptr;
}
m_scanner.slotCancel();
}

void Library::bindSidebarWidget(WLibrarySidebar* pSidebarWidget) {
m_pLibraryControl->bindSidebarWidget(pSidebarWidget);

Expand Down
2 changes: 2 additions & 0 deletions src/library/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Library: public QObject,
RecordingManager* pRecordingManager);
~Library() override;

void stopFeatures();

mixxx::DbConnectionPoolPtr dbConnectionPool() const {
return m_pDbConnectionPool;
}
Expand Down
5 changes: 4 additions & 1 deletion src/mixer/playermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ PlayerManager::~PlayerManager() {
delete m_pCONumMicrophones;
delete m_pCONumAuxiliaries;

m_pTrackAnalysisScheduler.reset();
if (m_pTrackAnalysisScheduler) {
m_pTrackAnalysisScheduler->stop();
m_pTrackAnalysisScheduler.reset();
}
}

void PlayerManager::bindToLibrary(Library* pLibrary) {
Expand Down
3 changes: 3 additions & 0 deletions src/mixxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,9 @@ void MixxxMainWindow::finalize() {
qWarning() << "WMainMenuBar was not deleted by our sendPostedEvents trick.";
}

qDebug() << t.elapsed(false).debugMillisWithUnit() << "stopping pending Library tasks";
m_pLibrary->stopFeatures();

// SoundManager depend on Engine and Config
qDebug() << t.elapsed(false).debugMillisWithUnit() << "deleting SoundManager";
delete m_pSoundManager;
Expand Down

0 comments on commit dcf6301

Please sign in to comment.