diff --git a/src/Config.h b/src/Config.h index 26b679c2..0a4174a9 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 5 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 1 -#define VER_LAMEXP_BUILD 1017 +#define VER_LAMEXP_BUILD 1018 /////////////////////////////////////////////////////////////////////////////// // Tool versions (minimum expected versions!) diff --git a/src/Dialog_WorkingBanner.cpp b/src/Dialog_WorkingBanner.cpp index 441a4779..f854788e 100644 --- a/src/Dialog_WorkingBanner.cpp +++ b/src/Dialog_WorkingBanner.cpp @@ -43,7 +43,7 @@ WorkingBanner::WorkingBanner(QWidget *parent) : QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint), - m_progressMax(0), m_progressVal(0) + m_progressMax(0), m_progressVal(0), m_metrics(NULL) { //Init the dialog, from the .ui file setupUi(this); @@ -90,6 +90,7 @@ WorkingBanner::~WorkingBanner(void) } LAMEXP_DELETE(m_progress); + LAMEXP_DELETE(m_metrics); } //////////////////////////////////////////////////////////// @@ -205,15 +206,19 @@ bool WorkingBanner::winEvent(MSG *message, long *result) void WorkingBanner::setText(const QString &text) { - QFontMetrics metrics(labelStatus->font()); - if(metrics.width(text) <= labelStatus->width()) + if(!m_metrics) + { + m_metrics = new QFontMetrics(labelStatus->font()); + } + + if(m_metrics->width(text) <= labelStatus->width()) { labelStatus->setText(text); } else { QString choppedText = text.simplified().append("..."); - while(metrics.width(choppedText) > labelStatus->width() && choppedText.length() > 8) + while((m_metrics->width(choppedText) > labelStatus->width()) && (choppedText.length() > 8)) { choppedText.chop(4); choppedText = choppedText.trimmed(); diff --git a/src/Dialog_WorkingBanner.h b/src/Dialog_WorkingBanner.h index b2b20b68..9072ca62 100644 --- a/src/Dialog_WorkingBanner.h +++ b/src/Dialog_WorkingBanner.h @@ -59,6 +59,7 @@ protected: bool winEvent(MSG *message, long *result); QLabel *m_progress; + QFontMetrics *m_metrics; unsigned int m_progressMax; unsigned int m_progressVal; }; diff --git a/src/Model_Progress.cpp b/src/Model_Progress.cpp index e6af8ef6..bb235410 100644 --- a/src/Model_Progress.cpp +++ b/src/Model_Progress.cpp @@ -23,7 +23,7 @@ #include -#define MAX_DISPLAY_ITEMS 32 +#define MAX_DISPLAY_ITEMS 48 ProgressModel::ProgressModel(void) : diff --git a/src/Thread_CueSplitter.cpp b/src/Thread_CueSplitter.cpp index 31b28008..d957924b 100644 --- a/src/Thread_CueSplitter.cpp +++ b/src/Thread_CueSplitter.cpp @@ -155,8 +155,7 @@ void CueSplitter::run() } int nFiles = m_model->getFileCount(); - int nTracksTotal = 0; - int nTracksComplete = 0; + int nTracksTotal = 0, nTracksComplete = 0; for(int i = 0; i < nFiles; i++) { diff --git a/src/Thread_FileAnalyzer.cpp b/src/Thread_FileAnalyzer.cpp index 8fdb1264..d407cc98 100644 --- a/src/Thread_FileAnalyzer.cpp +++ b/src/Thread_FileAnalyzer.cpp @@ -173,6 +173,10 @@ void FileAnalyzer::run() } else { + if(int count = AnalyzeTask::getAdditionalFiles(m_inputFiles)) + { + emit progressMaxChanged(nFiles += count); + } QThread::msleep(5); } } @@ -181,9 +185,10 @@ void FileAnalyzer::run() if(!m_bAborted) { pool->waitForDone(); - AnalyzeTask::getAdditionalFiles(m_inputFiles); - nFiles += m_inputFiles.count(); - emit progressMaxChanged(nFiles); + if(int count = AnalyzeTask::getAdditionalFiles(m_inputFiles)) + { + emit progressMaxChanged(nFiles += count); + } } } diff --git a/src/Thread_FileAnalyzer_Task.cpp b/src/Thread_FileAnalyzer_Task.cpp index c4a00812..39e14236 100644 --- a/src/Thread_FileAnalyzer_Task.cpp +++ b/src/Thread_FileAnalyzer_Task.cpp @@ -145,8 +145,9 @@ void AnalyzeTask::run_ex(void) QStringList fileList; if(PlaylistImporter::importPlaylist(fileList, currentFile)) { - QWriteLocker lock(&s_lock); + waitForPreviousThreads(); qDebug("Imported playlist file."); + QWriteLocker lock(&s_lock); s_additionalFiles << fileList; } else if(!QFileInfo(currentFile).suffix().compare("cue", Qt::CaseInsensitive)) @@ -164,6 +165,7 @@ void AnalyzeTask::run_ex(void) s_filesAccepted++; s_recentlyAdded.append(file.filePath()); lock.unlock(); + waitForPreviousThreads(); emit fileAnalyzed(file); } @@ -767,11 +769,22 @@ unsigned int AnalyzeTask::filesCueSheet(void) return s_filesCueSheet; } -void AnalyzeTask::getAdditionalFiles(QStringList &fileList) +int AnalyzeTask::getAdditionalFiles(QStringList &fileList) { - QReadLocker lock(&s_lock); - fileList << s_additionalFiles; - s_additionalFiles.clear(); + QReadLocker readLock(&s_lock); + int count = s_additionalFiles.count(); + readLock.unlock(); + + if(count > 0) + { + QWriteLocker lock(&s_lock); + count = s_additionalFiles.count(); + fileList << s_additionalFiles; + s_additionalFiles.clear(); + return count; + } + + return 0; } void AnalyzeTask::reset(void) diff --git a/src/Thread_FileAnalyzer_Task.h b/src/Thread_FileAnalyzer_Task.h index 5a43ef60..008e38b4 100644 --- a/src/Thread_FileAnalyzer_Task.h +++ b/src/Thread_FileAnalyzer_Task.h @@ -46,7 +46,7 @@ public: ~AnalyzeTask(void); static void reset(void); - static void getAdditionalFiles(QStringList &fileList); + static int getAdditionalFiles(QStringList &fileList); static unsigned int filesAccepted(void); static unsigned int filesRejected(void); static unsigned int filesDenied(void);