From 0b4c28342e621ab7c45b1a21ebe8d958a76dc634 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Wed, 16 Oct 2013 08:06:09 +0000 Subject: rgscan: fixed race condition git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3795 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/rgscan/rgscandialog.cpp | 2 +- src/plugins/General/rgscan/rgscanner.cpp | 14 +++++++++++++- src/plugins/General/rgscan/rgscanner.h | 5 +++-- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/General/rgscan/rgscandialog.cpp b/src/plugins/General/rgscan/rgscandialog.cpp index f7f867433..c935ad0b4 100644 --- a/src/plugins/General/rgscan/rgscandialog.cpp +++ b/src/plugins/General/rgscan/rgscandialog.cpp @@ -136,7 +136,7 @@ void RGScanDialog::onScanFinished(QString url) foreach (RGScanner *scanner, m_scanners) { - if(scanner->isRunning()) + if(scanner->isRunning() || scanner->isPending()) stopped = false; } diff --git a/src/plugins/General/rgscan/rgscanner.cpp b/src/plugins/General/rgscan/rgscanner.cpp index f40eeb599..a9c78adb8 100644 --- a/src/plugins/General/rgscan/rgscanner.cpp +++ b/src/plugins/General/rgscan/rgscanner.cpp @@ -30,6 +30,7 @@ RGScanner::RGScanner() m_peak = 0.; m_user_stop = false; m_is_running = false; + m_is_pending = false; m_has_values = false; m_handle = 0; m_decoder = 0; @@ -49,6 +50,7 @@ RGScanner::~RGScanner() bool RGScanner::prepare(const QString &url) { + m_is_pending = false; deinit(); m_url = url; QString name = m_url.section("/", -1); @@ -95,6 +97,7 @@ bool RGScanner::prepare(const QString &url) m_source = source; m_user_stop = false; m_has_values = false; + m_is_pending = true; return true; } @@ -105,11 +108,16 @@ void RGScanner::stop() m_mutex.unlock(); } -bool RGScanner::isRunning() +bool RGScanner::isRunning() const { return m_is_running; } +bool RGScanner::isPending() const +{ + return m_is_pending; +} + bool RGScanner::hasValues() const { return m_has_values; @@ -138,10 +146,14 @@ GainHandle_t *RGScanner::handle() void RGScanner::run() { if(m_user_stop) + { + m_is_pending = false; return; + } QString name = m_url.section("/", -1); qDebug("RGScanner: [%s] staring thread", qPrintable(name)); m_is_running = true; + m_is_pending = false; bool error = false; AudioParameters ap = m_decoder->audioParameters(); diff --git a/src/plugins/General/rgscan/rgscanner.h b/src/plugins/General/rgscan/rgscanner.h index f302ca08b..dad5b08a7 100644 --- a/src/plugins/General/rgscan/rgscanner.h +++ b/src/plugins/General/rgscan/rgscanner.h @@ -43,7 +43,8 @@ public: bool prepare(const QString &url); void stop(); - bool isRunning(); + bool isRunning() const; + bool isPending() const; bool hasValues() const; double gain() const; double peak() const; @@ -60,7 +61,7 @@ private: InputSource *m_source; Decoder *m_decoder; QMutex m_mutex; - bool m_user_stop, m_is_running, m_has_values; + bool m_user_stop, m_is_running, m_is_pending, m_has_values; QString m_url; double m_gain; double m_peak; -- cgit v1.2.3-13-gbd6f