Implemented workaround for VapourSynth plug-in loading: Testing shows that the environment variable %USERPROFILE% must be set correctly; otherwise VapourSynth fails to load plugins from the "<AppData>\VapourSynth\plugins{32|64}" directory.

Even though it would make more sense to evaluate %APPDATA%, VapourSynth apparently ignores that one. We set up %APPDATA% anyway, just to be sure.
This commit is contained in:
LoRd_MuldeR 2019-05-07 21:10:13 +02:00
parent dad84faa34
commit 798c41f7f8
6 changed files with 36 additions and 8 deletions

View File

@ -80,7 +80,7 @@ bool AbstractEncoder::runEncodingPass(AbstractSource* pipedSource, const QString
buildCommandLine(cmdLine_Encode, (pipedSource != NULL), clipInfo, m_indexFile, pass, passLogFile);
log("Creating encoder process:");
if(!startProcess(processEncode, getBinaryPath(), cmdLine_Encode, true, &getExtraPaths()))
if(!startProcess(processEncode, getBinaryPath(), cmdLine_Encode, true, &getExtraPaths(), &getExtraEnv()))
{
return false;
}

View File

@ -29,6 +29,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
#include <MUtils/Exception.h>
//Qt
@ -67,7 +68,7 @@ bool AbstractSource::checkSourceProperties(ClipInfo &clipInfo)
checkSourceProperties_init(patterns, cmdLine);
log("Creating process:");
if(!startProcess(process, getBinaryPath(), cmdLine, true, &getExtraPaths()))
if(!startProcess(process, getBinaryPath(), cmdLine, true, &getExtraPaths(), &getExtraEnv()))
{
return false;;
}
@ -191,7 +192,7 @@ bool AbstractSource::createProcess(QProcess &processEncode, QProcess&processInpu
buildCommandLine(cmdLine_Input);
log("Creating input process:");
if(!startProcess(processInput, getBinaryPath(), cmdLine_Input, false, &getExtraPaths()))
if(!startProcess(processInput, getBinaryPath(), cmdLine_Input, false, &getExtraPaths(), &getExtraEnv()))
{
return false;
}
@ -207,3 +208,26 @@ const AbstractSourceInfo& AbstractSource::getSourceInfo(void)
{
MUTILS_THROW("[getSourceInfo] This function must be overwritten in sub-classes!");
}
// ------------------------------------------------------------
// Auxiliary FUnctions
// ------------------------------------------------------------
QHash<QString, QString> AbstractSource::getExtraEnv(void) const
{
QHash<QString, QString> extraEnv;
const QString profilePath = MUtils::OS::known_folder(MUtils::OS::FOLDER_USER_PROFILE);
if (!profilePath.isEmpty())
{
extraEnv.insert("USERPROFILE", QDir::toNativeSeparators(profilePath));
}
const QString appDataPath = MUtils::OS::known_folder(MUtils::OS::FOLDER_ROAMING_DATA);
if (!appDataPath.isEmpty())
{
extraEnv.insert("APPDATA", QDir::toNativeSeparators(appDataPath));
}
return extraEnv;
}

View File

@ -50,6 +50,8 @@ public:
static const AbstractSourceInfo& getSourceInfo(void);
protected:
virtual QHash<QString, QString> getExtraEnv(void) const;
virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine) = 0;
virtual void checkSourceProperties_parseLine(const QString &line, const QList<QRegExp*> &patterns, ClipInfo &clipInfo) = 0;

View File

@ -217,7 +217,7 @@ void VapoursynthSource::checkSourceProperties_parseLine(const QString &line, con
}
// ------------------------------------------------------------
// Check Source Properties
// Source Processing
// ------------------------------------------------------------
void VapoursynthSource::buildCommandLine(QStringList &cmdLine)

View File

@ -94,7 +94,7 @@ unsigned int AbstractTool::checkVersion(bool &modified)
checkVersion_init(patterns, cmdLine);
log("Creating process:");
if(!startProcess(process, getBinaryPath(), cmdLine, true, &getExtraPaths()))
if(!startProcess(process, getBinaryPath(), cmdLine, true, &getExtraPaths(), &getExtraEnv()))
{
return false;
}
@ -173,12 +173,12 @@ bool AbstractTool::checkVersion_succeeded(const int &exitCode)
// Process Creation
// ------------------------------------------------------------
bool AbstractTool::startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels, const QStringList *const extraPaths)
bool AbstractTool::startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels, const QStringList *const extraPaths, const QHash<QString, QString> *const extraEnv)
{
QMutexLocker lock(&s_mutexStartProcess);
log(commandline2string(program, args) + "\n");
MUtils::init_process(process, QDir::tempPath(), true, extraPaths);
MUtils::init_process(process, QDir::tempPath(), true, extraPaths, extraEnv);
if(!mergeChannels)
{
process.setProcessChannelMode(QProcess::SeparateChannels);

View File

@ -25,6 +25,7 @@
#include <QUuid>
#include <QMutex>
#include <QStringList>
#include <QHash>
class OptionsModel;
class SysinfoModel;
@ -64,6 +65,7 @@ protected:
static const unsigned int m_processTimeoutWarning = 24;
virtual QString getBinaryPath(void) const = 0;
virtual QHash<QString, QString> getExtraEnv(void) const { return QHash<QString, QString>(); }
virtual QStringList getExtraPaths(void) const { return QStringList(); }
virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine) = 0;
@ -75,7 +77,7 @@ protected:
void setProgress(unsigned int newProgress) { emit progressChanged(newProgress); }
void setDetails(const QString &text) { emit detailsChanged(text); }
bool startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels = true, const QStringList *const extraPath = NULL);
bool startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels = true, const QStringList *const extraPath = NULL, const QHash<QString, QString> *const extraEnv = NULL);
JobObject *const m_jobObject;
const OptionsModel *const m_options;