diff --git a/src/thread_avisynth.cpp b/src/thread_avisynth.cpp index f9265b9..129fb3d 100644 --- a/src/thread_avisynth.cpp +++ b/src/thread_avisynth.cpp @@ -25,9 +25,7 @@ #include #include #include -#include #include -#include #include //Internal @@ -97,7 +95,7 @@ bool AvisynthCheckThread::detect(SysinfoModel *sysinfo) connect(&thread, SIGNAL(terminated()), &loop, SLOT(quit())); thread.start(); - QTimer::singleShot(15000, &loop, SLOT(quit())); + QTimer::singleShot(30000, &loop, SLOT(quit())); qDebug("Avisynth thread has been created, please wait..."); loop.exec(QEventLoop::ExcludeUserInputEvents); @@ -225,9 +223,6 @@ bool AvisynthCheckThread::checkAvisynth(QString &basePath, const SysinfoModel *c { qDebug("Avisynth %s-Bit support is being tested.", x64 ? "64" : "32"); - QProcess process; - QStringList output; - //Look for "portable" Avisynth version static const char *const ARCH_DIR[] = { "x64", "x86" }; const QLatin1String archSuffix = QLatin1String(ARCH_DIR[x64 ? 1 : 0]); @@ -245,56 +240,15 @@ bool AvisynthCheckThread::checkAvisynth(QString &basePath, const SysinfoModel *c } } + //Get extra paths + QStringList avisynthExtraPaths; + if (!basePath.isEmpty()) + { + avisynthExtraPaths << QString("%1/%2").arg(basePath, archSuffix); + } + //Setup process object - MUtils::init_process(process, QDir::tempPath(), true, basePath.isEmpty() ? NULL : &(QStringList() << QString("%1/%2").arg(basePath, archSuffix))); - - //Try to start VSPIPE.EXE - process.start(AVS_CHECK_BINARY(sysinfo, x64), QStringList()); - if(!process.waitForStarted()) - { - qWarning("Failed to launch AVS_CHECK.EXE -> %s", process.errorString().toUtf8().constData()); - return false; - } - - //Wait for process to finish - while(process.state() != QProcess::NotRunning) - { - if(process.waitForReadyRead(12000)) - { - while(process.canReadLine()) - { - output << QString::fromUtf8(process.readLine()).simplified(); - } - continue; - } - if(process.state() != QProcess::NotRunning) - { - qWarning("AVS_CHECK.EXE process encountered a deadlock -> aborting now!"); - break; - } - } - - //Make sure VSPIPE.EXE has terminated! - process.waitForFinished(2500); - if(process.state() != QProcess::NotRunning) - { - qWarning("AVS_CHECK.EXE process still running, going to kill it!"); - process.kill(); - process.waitForFinished(-1); - } - - //Read pending lines - while(process.canReadLine()) - { - output << QString::fromUtf8(process.readLine()).simplified(); - } - - //Check exit code - if(process.exitCode() != 0) - { - qWarning("AVS_CHECK.EXE failed with code 0x%08X -> disable Avisynth support!", process.exitCode()); - return false; - } + const QStringList output = runProcess(AVS_CHECK_BINARY(sysinfo, x64), QStringList(), &avisynthExtraPaths); //Init regular expressions QRegExp avsLogo("Avisynth\\s+Checker\\s+(x86|x64)"); diff --git a/src/thread_avisynth.h b/src/thread_avisynth.h index 17617dc..7570a9c 100644 --- a/src/thread_avisynth.h +++ b/src/thread_avisynth.h @@ -21,14 +21,14 @@ #pragma once -#include +#include "thread_startup.h" + #include -class QLibrary; class SysinfoModel; class QFile; -class AvisynthCheckThread : public QThread +class AvisynthCheckThread : public StarupThread { Q_OBJECT diff --git a/src/thread_startup.cpp b/src/thread_startup.cpp new file mode 100644 index 0000000..9b7adff --- /dev/null +++ b/src/thread_startup.cpp @@ -0,0 +1,101 @@ +/////////////////////////////////////////////////////////////////////////////// +// Simple x264 Launcher +// Copyright (C) 2004-2019 LoRd_MuldeR +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// http://www.gnu.org/licenses/gpl-2.0.txt +/////////////////////////////////////////////////////////////////////////////// + +#include "thread_startup.h" + +//MUtils +#include + +//Qt +#include +#include +#include + +QStringList StarupThread::runProcess(const QString &exePath, const QStringList &arguments, const QStringList *const extraPaths) +{ + QProcess process; + + //Get file name + const QString fileName = QFileInfo(exePath).fileName().toUpper(); + + //Setup process object + MUtils::init_process(process, QDir::tempPath(), true, extraPaths); + + //Try to start process + process.start(exePath, arguments); + if (!process.waitForStarted()) + { + qWarning("Failed to launch %s -> %s", MUTILS_UTF8(fileName), MUTILS_UTF8(process.errorString())); + return QStringList(); + } + + //Start the timer + QElapsedTimer timer; + timer.start(); + + //Wait until process has finished + QStringList processOutput; + while (process.state() != QProcess::NotRunning) + { + process.waitForReadyRead(1250); + while (process.canReadLine()) + { + const QString line = QString::fromUtf8(process.readLine()).simplified(); + if (!line.isEmpty()) + { + processOutput << line; + } + } + if (timer.hasExpired(15000)) + { + qWarning("%s process encountered a deadlock -> aborting now!", MUTILS_UTF8(fileName)); + break; + } + } + + //Make sure process has terminated! + process.waitForFinished(1250); + if (process.state() != QProcess::NotRunning) + { + qWarning("%s process still running, going to kill it!", MUTILS_UTF8(fileName)); + process.kill(); + process.waitForFinished(-1); + } + + //Read pending lines + while (process.bytesAvailable() > 0) + { + const QString line = QString::fromUtf8(process.readLine()).simplified(); + if (!line.isEmpty()) + { + processOutput << line; + } + } + + //Check exit code + if (process.exitCode() != 0) + { + qWarning("%s failed with code 0x%08X -> discarding all output!", MUTILS_UTF8(fileName), process.exitCode()); + return QStringList(); + } + + return processOutput; +} diff --git a/src/thread_startup.h b/src/thread_startup.h new file mode 100644 index 0000000..d187bf2 --- /dev/null +++ b/src/thread_startup.h @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////// +// Simple x264 Launcher +// Copyright (C) 2004-2019 LoRd_MuldeR +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// http://www.gnu.org/licenses/gpl-2.0.txt +/////////////////////////////////////////////////////////////////////////////// + +#pragma once + +//Qt +#include +#include + +class StarupThread : public QThread +{ + Q_OBJECT + +protected: + static QStringList runProcess(const QString &exePath, const QStringList &args, const QStringList *const extraPaths = NULL); +}; diff --git a/src/thread_vapoursynth.cpp b/src/thread_vapoursynth.cpp index dea90df..26e6361 100644 --- a/src/thread_vapoursynth.cpp +++ b/src/thread_vapoursynth.cpp @@ -29,10 +29,8 @@ #include #include #include -#include #include #include -#include //Internal #include "global.h" @@ -86,7 +84,7 @@ bool VapourSynthCheckThread::detect(SysinfoModel *sysinfo) connect(&thread, SIGNAL(terminated()), &loop, SLOT(quit())); thread.start(); - QTimer::singleShot(15000, &loop, SLOT(quit())); + QTimer::singleShot(30000, &loop, SLOT(quit())); qDebug("VapourSynth thread has been created, please wait..."); loop.exec(QEventLoop::ExcludeUserInputEvents); @@ -336,61 +334,8 @@ bool VapourSynthCheckThread::isVapourSynthComplete(const QString &vsCorePath, QF bool VapourSynthCheckThread::checkVapourSynth(const QString &vspipePath) { - QProcess process; - QStringList output; - - //Setup process object - process.setWorkingDirectory(QDir::tempPath()); - process.setProcessChannelMode(QProcess::MergedChannels); - process.setReadChannel(QProcess::StandardOutput); - - //Try to start VSPIPE.EXE - process.start(vspipePath, QStringList() << "--version"); - if(!process.waitForStarted()) - { - qWarning("Failed to launch VSPIPE.EXE -> %s", process.errorString().toUtf8().constData()); - return false; - } - - //Wait for process to finish - while(process.state() != QProcess::NotRunning) - { - if(process.waitForReadyRead(12000)) - { - while(process.canReadLine()) - { - output << QString::fromUtf8(process.readLine()).simplified(); - } - continue; - } - if(process.state() != QProcess::NotRunning) - { - qWarning("VSPIPE.EXE process encountered a deadlock -> aborting now!"); - break; - } - } - - //Make sure VSPIPE.EXE has terminated! - process.waitForFinished(2500); - if(process.state() != QProcess::NotRunning) - { - qWarning("VSPIPE.EXE process still running, going to kill it!"); - process.kill(); - process.waitForFinished(-1); - } - - //Read pending lines - while(process.canReadLine()) - { - output << QString::fromUtf8(process.readLine()).simplified(); - } - - //Check exit code - if(process.exitCode() != 0) - { - qWarning("VSPIPE.EXE failed with code 0x%08X -> disable Vapousynth support!", process.exitCode()); - return false; - } + //Try to run VSPIPE.EXE + const QStringList output = runProcess(vspipePath, QStringList() << "--version"); //Init regular expressions QRegExp vpsLogo("VapourSynth\\s+Video\\s+Processing\\s+Library"); diff --git a/src/thread_vapoursynth.h b/src/thread_vapoursynth.h index f8a9639..ddc514b 100644 --- a/src/thread_vapoursynth.h +++ b/src/thread_vapoursynth.h @@ -21,15 +21,15 @@ #pragma once +#include "thread_startup.h" + //Qt -#include #include -class QLibrary; class QFile; class SysinfoModel; -class VapourSynthCheckThread : public QThread +class VapourSynthCheckThread : public StarupThread { Q_OBJECT diff --git a/src/version.h b/src/version.h index f9cdd0e..5c0715f 100644 --- a/src/version.h +++ b/src/version.h @@ -26,7 +26,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 9 #define VER_X264_PATCH 0 -#define VER_X264_BUILD 1146 +#define VER_X264_BUILD 1154 #define VER_X264_PORTABLE_EDITION (0) diff --git a/x264_launcher.props b/x264_launcher.props new file mode 100644 index 0000000..5f534de --- /dev/null +++ b/x264_launcher.props @@ -0,0 +1,14 @@ + + + + + false + + + + + + $(XPDeprecationWarning) + + + \ No newline at end of file diff --git a/x264_launcher_MSVC2017.vcxproj b/x264_launcher_MSVC2017.vcxproj index fe43fc4..1d16863 100644 --- a/x264_launcher_MSVC2017.vcxproj +++ b/x264_launcher_MSVC2017.vcxproj @@ -36,9 +36,11 @@ + + @@ -262,7 +264,6 @@ copy /Y "$(ProjectDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\plugins\im $(SolutionDir)tmp\$(ProjectName)\UIC_%(Filename).h;%(Outputs) $(SolutionDir)tmp\$(ProjectName)\UIC_%(Filename).h;%(Outputs) - Document "$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)" @@ -304,6 +305,14 @@ copy /Y "$(ProjectDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\plugins\im + + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)" + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)" + MOC "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" + MOC "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" + $(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs) + $(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs) + @@ -470,6 +479,7 @@ copy /Y "$(ProjectDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\plugins\im + @@ -488,6 +498,7 @@ copy /Y "$(ProjectDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\plugins\im + diff --git a/x264_launcher_MSVC2017.vcxproj.filters b/x264_launcher_MSVC2017.vcxproj.filters index 89f52d3..ebcb88f 100644 --- a/x264_launcher_MSVC2017.vcxproj.filters +++ b/x264_launcher_MSVC2017.vcxproj.filters @@ -24,7 +24,6 @@ - Resource Files @@ -120,6 +119,9 @@ Header Files + + Header Files + @@ -284,6 +286,12 @@ Source Files + + Source Files + + + Generated Files + diff --git a/z_build.bat b/z_build.bat index baf8e8f..d38415d 100644 --- a/z_build.bat +++ b/z_build.bat @@ -145,9 +145,9 @@ REM /////////////////////////////////////////////////////////////////////////// REM /////////////////////////////////////////////////////////////////////////// REM // Compress REM /////////////////////////////////////////////////////////////////////////// -"%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\x264_launcher.exe" -"%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\MUtils32-1.dll" -"%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\Qt*.dll" +:: "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\x264_launcher.exe" +:: "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\MUtils32-1.dll" +:: "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\Qt*.dll" REM /////////////////////////////////////////////////////////////////////////// REM // Attributes