From 092e664ad15c4f3faceba31624dd2b8a90e9b046 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Thu, 18 Nov 2010 22:37:35 +0100 Subject: [PATCH] More detailed error output when process failed to create + use UUID's to index jobs. --- gui/ProcessingDialog.ui | 8 +++++++- res/icons/media_play.png | Bin 0 -> 663 bytes src/Config.h | 2 +- src/Dialog_Processing.cpp | 11 ++++++++--- src/Model_Progress.cpp | 28 +++++++++++++--------------- src/Model_Progress.h | 13 +++++++------ src/Thread_FileAnalyzer.cpp | 9 +++++---- src/Thread_Initialization.cpp | 7 +++---- src/Thread_Process.cpp | 9 ++++----- src/Thread_Process.h | 7 ++++--- 10 files changed, 52 insertions(+), 42 deletions(-) create mode 100644 res/icons/media_play.png diff --git a/gui/ProcessingDialog.ui b/gui/ProcessingDialog.ui index 372b6ade..af5e531e 100644 --- a/gui/ProcessingDialog.ui +++ b/gui/ProcessingDialog.ui @@ -13,6 +13,10 @@ LameXP - Processing + + + :/icons/sound.png:/icons/sound.png + 0 @@ -169,7 +173,7 @@ - 12 + 16 20 @@ -428,6 +432,8 @@ + + diff --git a/res/icons/media_play.png b/res/icons/media_play.png new file mode 100644 index 0000000000000000000000000000000000000000..8d66deb68c06280ca4c1056690a7e65a07f162a9 GIT binary patch literal 663 zcmV;I0%-k-P)WdKBJATc-~MrC3kGB7YRATlyKGC4XmHy|r8F)%R12)vj8000McNliru z(*hb5Hwt$p2nzrJ010qNS#tmY3h)2`3h)6!tTdPa000DMK}|sb0I`n?{9y$E00Hkw zL_t(|+O3mKYg0iKhMzk#xw(l3n`r6>Ru`J8sTioMAc6ra?g}oY3pcI=(LYddY$-&c>QdNn z$=6`1VzW@JvmTBZ#1EWhd+sf%7o!}0;{W{#gfxl`_*OS4Gz{`}L9r=m3JHOLZt{S| zk$pGlS8q7~YOn*~N=4ZgtT~dBEm^e{`28&@of`&3qmWDV6z z*Yt{-FJ(&}#MDKf&s#ek0Ph4%t%g=zxw>Ms&7RRyJ`Z!*SwwiG1AvkSO4CgZH#IH9A%x-5R3BG`9@XZy3ijBtT x)Q=dRy0o*eXRNSN{oty|H6A2py8VMKiSOp5p)mkU&0PQh002ovPDHLkV1f&R9rpkL literal 0 HcmV?d00001 diff --git a/src/Config.h b/src/Config.h index 8f40093f..ec446483 100644 --- a/src/Config.h +++ b/src/Config.h @@ -25,7 +25,7 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 0 -#define VER_LAMEXP_BUILD 38 +#define VER_LAMEXP_BUILD 40 #define VER_LAMEXP_SUFFIX TechPreview /* diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index 755a4c2b..f1cabe66 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -45,9 +45,14 @@ ProcessingDialog::ProcessingDialog(void) //Init the dialog, from the .ui file setupUi(this); setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint); + + //Setup version info label_versionInfo->setText(QString().sprintf("v%d.%02d %s (Build %d)", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build())); label_versionInfo->installEventFilter(this); + //Register meta type + qRegisterMetaType("QUuid"); + //Center window in screen QRect desktopRect = QApplication::desktop()->screenGeometry(); QRect thisRect = this->geometry(); @@ -102,7 +107,7 @@ void ProcessingDialog::showEvent(QShowEvent *event) void ProcessingDialog::closeEvent(QCloseEvent *event) { - if(!button_closeDialog->isEnabled() || m_thread) event->ignore(); + if(!button_closeDialog->isEnabled()) event->ignore(); } bool ProcessingDialog::eventFilter(QObject *obj, QEvent *event) @@ -149,8 +154,8 @@ void ProcessingDialog::initEncoding(void) { m_thread[i] = new ProcessThread(); connect(m_thread[i], SIGNAL(finished()), this, SLOT(doneEncoding()), Qt::QueuedConnection); - connect(m_thread[i], SIGNAL(processStateInitialized(QString,QString,QString,int)), m_progressModel, SLOT(addJob(QString,QString,QString,int)), Qt::QueuedConnection); - connect(m_thread[i], SIGNAL(processStateChanged(QString,QString,int)), m_progressModel, SLOT(updateJob(QString,QString,int)), Qt::QueuedConnection); + connect(m_thread[i], SIGNAL(processStateInitialized(QUuid,QString,QString,int)), m_progressModel, SLOT(addJob(QUuid,QString,QString,int)), Qt::QueuedConnection); + connect(m_thread[i], SIGNAL(processStateChanged(QUuid,QString,int)), m_progressModel, SLOT(updateJob(QUuid,QString,int)), Qt::QueuedConnection); m_thread[i]->start(); } diff --git a/src/Model_Progress.cpp b/src/Model_Progress.cpp index 3467e031..7ea749df 100644 --- a/src/Model_Progress.cpp +++ b/src/Model_Progress.cpp @@ -21,6 +21,8 @@ #include "Model_Progress.h" +#include + ProgressModel::ProgressModel(void) : m_iconRunning(":/icons/media_play.png"), m_iconPaused(":/icons/control_pause_blue.png"), @@ -113,34 +115,30 @@ QVariant ProgressModel::headerData(int section, Qt::Orientation orientation, int return QVariant(); } -void ProgressModel::addJob(const QString &jobId, const QString &jobName, const QString &jobInitialStatus, int jobInitialState) +void ProgressModel::addJob(const QUuid &jobId, const QString &jobName, const QString &jobInitialStatus, int jobInitialState) { - if(m_jobList.contains(jobId, Qt::CaseInsensitive)) + if(m_jobList.contains(jobId)) { return; } - QString id = jobId.toLower(); - beginResetModel(); - m_jobList.append(id); - m_jobName.insert(id, jobName); - m_jobStatus.insert(id, jobInitialStatus); - m_jobState.insert(id, jobInitialState); + m_jobList.append(jobId); + m_jobName.insert(jobId, jobName); + m_jobStatus.insert(jobId, jobInitialStatus); + m_jobState.insert(jobId, jobInitialState); endResetModel(); } -void ProgressModel::updateJob(const QString &jobId, const QString &newStatus, int newState) +void ProgressModel::updateJob(const QUuid &jobId, const QString &newStatus, int newState) { - if(!m_jobList.contains(jobId, Qt::CaseInsensitive)) + if(!m_jobList.contains(jobId)) { return; } - - QString id = jobId.toLower(); - + beginResetModel(); - if(!newStatus.isEmpty()) m_jobStatus.insert(id, newStatus); - if(newState >= 0) m_jobState.insert(id, newState); + if(!newStatus.isEmpty()) m_jobStatus.insert(jobId, newStatus); + if(newState >= 0) m_jobState.insert(jobId, newState); endResetModel(); } diff --git a/src/Model_Progress.h b/src/Model_Progress.h index 6abf4ca2..8e0564c1 100644 --- a/src/Model_Progress.h +++ b/src/Model_Progress.h @@ -27,6 +27,7 @@ #include #include #include +#include class ProgressModel : public QAbstractTableModel { @@ -52,14 +53,14 @@ public: QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; public slots: - void addJob(const QString &jobId, const QString &jobName, const QString &jobInitialStatus = QString("Initializing..."), int jobInitialState = JobRunning); - void updateJob(const QString &jobId, const QString &newStatus, int newState); + void addJob(const QUuid &jobId, const QString &jobName, const QString &jobInitialStatus = QString("Initializing..."), int jobInitialState = JobRunning); + void updateJob(const QUuid &jobId, const QString &newStatus, int newState); private: - QStringList m_jobList; - QMap m_jobName; - QMap m_jobStatus; - QMap m_jobState; + QList m_jobList; + QMap m_jobName; + QMap m_jobStatus; + QMap m_jobState; const QIcon m_iconRunning; const QIcon m_iconPaused; diff --git a/src/Thread_FileAnalyzer.cpp b/src/Thread_FileAnalyzer.cpp index ac3a6853..0182af26 100644 --- a/src/Thread_FileAnalyzer.cpp +++ b/src/Thread_FileAnalyzer.cpp @@ -116,6 +116,7 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath) if(!process.waitForStarted()) { qWarning("MediaInfo process failed to create!"); + qWarning("Error message: \"%s\"\n", process.errorString().toLatin1().constData()); process.kill(); process.waitForFinished(-1); return audioFile; @@ -134,10 +135,11 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath) } } - QByteArray data = process.readLine().constData(); - while(data.size() > 0) + QByteArray data; + + while(process.canReadLine()) { - QString line = QString::fromUtf8(data).simplified(); + QString line = QString::fromUtf8(process.readLine().constData()).simplified(); if(!line.isEmpty()) { int index = line.indexOf(':'); @@ -155,7 +157,6 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath) updateSection(line); } } - data = process.readLine().constData(); } } diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index 3835c924..8f7f6be2 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -177,6 +177,7 @@ void InitializationThread::initNeroAac(void) if(!process.waitForStarted()) { qWarning("Nero process failed to create!"); + qWarning("Error message: \"%s\"\n", process.errorString().toLatin1().constData()); process.kill(); process.waitForFinished(-1); for(int i = 0; i < 3; i++) LAMEXP_DELETE(neroBin[i]); @@ -199,10 +200,9 @@ void InitializationThread::initNeroAac(void) } } - QByteArray data = process.readLine(); - while(!data.isEmpty()) + while(process.canReadLine()) { - QString line = QString::fromUtf8(data.constData()).simplified(); + QString line = QString::fromUtf8(process.readLine().constData()).simplified(); QStringList tokens = line.split(" ", QString::SkipEmptyParts, Qt::CaseInsensitive); int index1 = tokens.indexOf("Package"); int index2 = tokens.indexOf("version:"); @@ -218,7 +218,6 @@ void InitializationThread::initNeroAac(void) neroVersion += versionTokens.at(0).toInt() * 1000; } } - data = process.readLine(); } } diff --git a/src/Thread_Process.cpp b/src/Thread_Process.cpp index 2829d6ab..f7e4d197 100644 --- a/src/Thread_Process.cpp +++ b/src/Thread_Process.cpp @@ -33,7 +33,7 @@ //////////////////////////////////////////////////////////// ProcessThread::ProcessThread(void) - : m_jobId(QUuid::createUuid().toString()), m_aborted(false) + : m_jobId(QUuid::createUuid()), m_aborted(false) { } @@ -45,11 +45,11 @@ void ProcessThread::run() { m_aborted = false; - qDebug("Process thread %s has started.", m_jobId.toLatin1().constData()); + qDebug("Process thread %s has started.", m_jobId.toString().toLatin1().constData()); emit processStateInitialized(m_jobId, "Slime - Der Tod Ist Ein Meister Aus Deutschland.mp3", "Starting...", ProgressModel::JobRunning); QUuid uuid = QUuid::createUuid(); - qsrand(uuid.data1 * uuid.data2 * uuid.data3); + qsrand(uuid.data1 * uuid.data2 * uuid.data3 * uuid.data4[0] * uuid.data4[1] * uuid.data4[2] * uuid.data4[3] * uuid.data4[4] * uuid.data4[5] * uuid.data4[6] * uuid.data4[7]); unsigned long delay = 250 + (qrand() % 500); @@ -63,11 +63,10 @@ void ProcessThread::run() QThread::msleep(delay); emit processStateChanged(m_jobId, QString("Encoding (%1%)").arg(i), ProgressModel::JobRunning); - qDebug("Process thread is alive."); } emit processStateChanged(m_jobId, "Done (100%)", ProgressModel::JobComplete); - qDebug("Process thread is about to die..."); + qDebug("Process thread is done."); } //////////////////////////////////////////////////////////// diff --git a/src/Thread_Process.h b/src/Thread_Process.h index 551fe8e7..158fc005 100644 --- a/src/Thread_Process.h +++ b/src/Thread_Process.h @@ -22,6 +22,7 @@ #pragma once #include +#include class ProcessThread: public QThread { @@ -34,10 +35,10 @@ public: void abort() { m_aborted = true; } signals: - void processStateInitialized(const QString &jobId, const QString &jobName, const QString &jobInitialStatus, int jobInitialState); - void processStateChanged(const QString &jobId, const QString &newStatus, int newState); + void processStateInitialized(const QUuid &jobId, const QString &jobName, const QString &jobInitialStatus, int jobInitialState); + void processStateChanged(const QUuid &jobId, const QString &newStatus, int newState); private: - const QString m_jobId; + const QUuid m_jobId; volatile bool m_aborted; };