Some improvements to binary checker thread.
This commit is contained in:
parent
b8e5f3795c
commit
40fe40be80
@ -56,7 +56,7 @@ QString AVS_CHECK_BINARY(const SysinfoModel *sysinfo, const bool& x64);
|
|||||||
// External API
|
// External API
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
|
||||||
bool BinariesCheckThread::check(SysinfoModel *sysinfo)
|
bool BinariesCheckThread::check(const SysinfoModel *const sysinfo, QString *const failedPath)
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_binLock);
|
QMutexLocker lock(&m_binLock);
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ bool BinariesCheckThread::check(SysinfoModel *sysinfo)
|
|||||||
|
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
if(!thread.wait(1000))
|
if(!thread.wait(5000))
|
||||||
{
|
{
|
||||||
qWarning("Binaries checker thread encountered timeout -> probably deadlock!");
|
qWarning("Binaries checker thread encountered timeout -> probably deadlock!");
|
||||||
thread.terminate();
|
thread.terminate();
|
||||||
@ -91,7 +91,13 @@ bool BinariesCheckThread::check(SysinfoModel *sysinfo)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return thread.getSuccess();
|
const bool success = thread.getSuccess();
|
||||||
|
if ((!success) && failedPath)
|
||||||
|
{
|
||||||
|
*failedPath = thread.getFailedPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
@ -112,14 +118,15 @@ BinariesCheckThread::~BinariesCheckThread(void)
|
|||||||
void BinariesCheckThread::run(void)
|
void BinariesCheckThread::run(void)
|
||||||
{
|
{
|
||||||
m_success = m_exception = false;
|
m_success = m_exception = false;
|
||||||
checkBinaries1(m_success, m_sysinfo, &m_exception);
|
m_failedPath = QString();
|
||||||
|
checkBinaries1(m_success, m_failedPath, m_sysinfo, &m_exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinariesCheckThread::checkBinaries1(volatile bool &success, const SysinfoModel *const sysinfo, volatile bool *exception)
|
void BinariesCheckThread::checkBinaries1(volatile bool &success, QString &failedPath, const SysinfoModel *const sysinfo, volatile bool *exception)
|
||||||
{
|
{
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
checkBinaries2(success, sysinfo, exception);
|
checkBinaries2(success, failedPath, sysinfo, exception);
|
||||||
}
|
}
|
||||||
__except(1)
|
__except(1)
|
||||||
{
|
{
|
||||||
@ -128,11 +135,11 @@ void BinariesCheckThread::checkBinaries1(volatile bool &success, const SysinfoMo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinariesCheckThread::checkBinaries2(volatile bool &success, const SysinfoModel *const sysinfo, volatile bool *exception)
|
void BinariesCheckThread::checkBinaries2(volatile bool &success, QString &failedPath, const SysinfoModel *const sysinfo, volatile bool *exception)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return checkBinaries3(success, sysinfo);
|
return checkBinaries3(success, failedPath, sysinfo);
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
@ -141,7 +148,7 @@ void BinariesCheckThread::checkBinaries2(volatile bool &success, const SysinfoMo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinariesCheckThread::checkBinaries3(volatile bool &success, const SysinfoModel *const sysinfo)
|
void BinariesCheckThread::checkBinaries3(volatile bool &success, QString &failedPath, const SysinfoModel *const sysinfo)
|
||||||
{
|
{
|
||||||
success = true;
|
success = true;
|
||||||
|
|
||||||
@ -202,6 +209,7 @@ void BinariesCheckThread::checkBinaries3(volatile bool &success, const SysinfoMo
|
|||||||
{
|
{
|
||||||
if (!MUtils::OS::is_executable_file(file->fileName()))
|
if (!MUtils::OS::is_executable_file(file->fileName()))
|
||||||
{
|
{
|
||||||
|
failedPath = file->fileName();
|
||||||
success = false;
|
success = false;
|
||||||
qWarning("Required tool does NOT look like a valid Win32/Win64 binary:\n%s\n", MUTILS_UTF8(file->fileName()));
|
qWarning("Required tool does NOT look like a valid Win32/Win64 binary:\n%s\n", MUTILS_UTF8(file->fileName()));
|
||||||
return;
|
return;
|
||||||
@ -211,6 +219,7 @@ void BinariesCheckThread::checkBinaries3(volatile bool &success, const SysinfoMo
|
|||||||
{
|
{
|
||||||
if (!MUtils::OS::is_library_file(file->fileName()))
|
if (!MUtils::OS::is_library_file(file->fileName()))
|
||||||
{
|
{
|
||||||
|
failedPath = file->fileName();
|
||||||
success = false;
|
success = false;
|
||||||
qWarning("Required tool does NOT look like a valid Win32/Win64 library:\n%s\n", MUTILS_UTF8(file->fileName()));
|
qWarning("Required tool does NOT look like a valid Win32/Win64 library:\n%s\n", MUTILS_UTF8(file->fileName()));
|
||||||
return;
|
return;
|
||||||
@ -225,6 +234,7 @@ void BinariesCheckThread::checkBinaries3(volatile bool &success, const SysinfoMo
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
failedPath = file->fileName();
|
||||||
success = false;
|
success = false;
|
||||||
qWarning("Required tool could not be found or access denied:\n%s\n", MUTILS_UTF8(file->fileName()));
|
qWarning("Required tool could not be found or access denied:\n%s\n", MUTILS_UTF8(file->fileName()));
|
||||||
return;
|
return;
|
||||||
|
@ -33,7 +33,7 @@ class BinariesCheckThread : public QThread
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool check(SysinfoModel *sysinfo);
|
static bool check(const SysinfoModel *const sysinfo, QString *const failedPath = NULL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BinariesCheckThread(const SysinfoModel *const sysinfo);
|
BinariesCheckThread(const SysinfoModel *const sysinfo);
|
||||||
@ -42,12 +42,14 @@ protected:
|
|||||||
int getSuccess(void) { return m_success; }
|
int getSuccess(void) { return m_success; }
|
||||||
bool getException(void) { return m_exception; }
|
bool getException(void) { return m_exception; }
|
||||||
|
|
||||||
|
const QString& getFailedPath(void) { return m_failedPath; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void start(Priority priority = InheritPriority) { QThread::start(priority); }
|
void start(Priority priority = InheritPriority) { QThread::start(priority); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
volatile bool m_exception;
|
volatile bool m_exception, m_success;
|
||||||
volatile bool m_success;
|
QString m_failedPath;
|
||||||
const SysinfoModel *const m_sysinfo;
|
const SysinfoModel *const m_sysinfo;
|
||||||
|
|
||||||
static const size_t MAX_BINARIES = 32;
|
static const size_t MAX_BINARIES = 32;
|
||||||
@ -58,7 +60,7 @@ private:
|
|||||||
virtual void run(void);
|
virtual void run(void);
|
||||||
|
|
||||||
//Functions
|
//Functions
|
||||||
static void checkBinaries1(volatile bool &success, const SysinfoModel *const sysinfo, volatile bool *exception);
|
static void checkBinaries1(volatile bool &success, QString &failedPath, const SysinfoModel *const sysinfo, volatile bool *exception);
|
||||||
static void checkBinaries2(volatile bool &success, const SysinfoModel *const sysinfo, volatile bool *exception);
|
static void checkBinaries2(volatile bool &success, QString &failedPath, const SysinfoModel *const sysinfo, volatile bool *exception);
|
||||||
static void checkBinaries3(volatile bool &success, const SysinfoModel *const sysinfo);
|
static void checkBinaries3(volatile bool &success, QString &failedPath, const SysinfoModel *const sysinfo);
|
||||||
};
|
};
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include <QMovie>
|
#include <QMovie>
|
||||||
|
#include <QTextDocument>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
//Constants
|
//Constants
|
||||||
@ -894,10 +894,11 @@ void MainWindow::init(void)
|
|||||||
//---------------------------------------
|
//---------------------------------------
|
||||||
|
|
||||||
qDebug("[Validating binaries]");
|
qDebug("[Validating binaries]");
|
||||||
if(!BinariesCheckThread::check(m_sysinfo.data()))
|
QString failedPath;
|
||||||
|
if(!BinariesCheckThread::check(m_sysinfo.data(), &failedPath))
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, tr("Invalid File!"), tr("<nobr>At least one tool is missing or is not a valid Win32/Win64 binary.<br>Please re-install the program in order to fix the problem!</nobr>").replace("-", "−"));
|
QMessageBox::critical(this, tr("Invalid File!"), tr("<nobr>At least one tool is missing or is not a valid Win32/Win64 binary:</nobr><br><tt>%1</tt><br><br><nobr>Please re-install the program in order to fix the problem!</nobr>").replace("-", "−").arg(Qt::escape(QDir::toNativeSeparators(failedPath))));
|
||||||
qFatal("At least one tool is missing or is not a valid Win32/Win64 binary!");
|
qFatal("At least one tool is missing or is not a valid Win32/Win64 binary. Program will exit now!");
|
||||||
}
|
}
|
||||||
qDebug(" ");
|
qDebug(" ");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user