Commit 9b7b423f authored by Vincent Pinon's avatar Vincent Pinon

Fix bin/melt.exe & libmlt* loading on Windows

parent 2d3be73e
......@@ -75,6 +75,8 @@ int main(int argc, char *argv[])
#ifdef Q_OS_WIN
qputenv("KDE_FORK_SLAVES", "1");
QString path = qApp->applicationDirPath() + QLatin1Char(';') + qgetenv("PATH");
qputenv("PATH", path.toUtf8().constData());
#endif
app.setApplicationName(QStringLiteral("kdenlive"));
......
......@@ -42,17 +42,23 @@ void MltConnection::locateMeltAndProfilesPath(const QString &mltPath)
{
QString profilePath = mltPath;
//environment variables should override other settings
if (profilePath.isEmpty() || !QFile::exists(profilePath)) profilePath = qgetenv("MLT_PROFILES_PATH");
if (profilePath.isEmpty() || !QFile::exists(profilePath)) profilePath = qgetenv("MLT_DATA") + QStringLiteral("/profiles/");
if (profilePath.isEmpty() || !QFile::exists(profilePath)) profilePath = qgetenv("MLT_PREFIX") + QStringLiteral("/share/mlt/profiles/");
if ((profilePath.isEmpty() || !QFile::exists(profilePath)) && qEnvironmentVariableIsSet("MLT_PROFILES_PATH"))
profilePath = qgetenv("MLT_PROFILES_PATH");
if ((profilePath.isEmpty() || !QFile::exists(profilePath)) && qEnvironmentVariableIsSet("MLT_DATA"))
profilePath = qgetenv("MLT_DATA") + QStringLiteral("/profiles");
if ((profilePath.isEmpty() || !QFile::exists(profilePath)) && qEnvironmentVariableIsSet("MLT_PREFIX"))
profilePath = qgetenv("MLT_PREFIX") + QStringLiteral("/share/mlt/profiles");
#ifndef Q_OS_WIN
//stored setting should not be considered on windows as MLT is distributed with each new Kdenlive version
if (profilePath.isEmpty() || !QFile::exists(profilePath)) profilePath = KdenliveSettings::mltpath();
if ((profilePath.isEmpty() || !QFile::exists(profilePath)) && !KdenliveSettings::mltpath().isEmpty())
profilePath = KdenliveSettings::mltpath();
#endif
//try to automatically guess MLT path if installed with the same prefix as kdenlive with default data path
if (profilePath.isEmpty() || !QFile::exists(profilePath)) profilePath = QDir::cleanPath(qApp->applicationDirPath() + QStringLiteral("/../share/mlt/profiles/"));
if (profilePath.isEmpty() || !QFile::exists(profilePath))
profilePath = QDir::cleanPath(qApp->applicationDirPath() + QStringLiteral("/../share/mlt/profiles"));
//fallback to build-time definition
if ((profilePath.isEmpty() || !QFile::exists(profilePath)) && !QStringLiteral(MLT_DATADIR).isEmpty()) profilePath = QStringLiteral(MLT_DATADIR) + QStringLiteral("/profiles/");
if ((profilePath.isEmpty() || !QFile::exists(profilePath)) && !QStringLiteral(MLT_DATADIR).isEmpty())
profilePath = QStringLiteral(MLT_DATADIR) + QStringLiteral("/profiles");
KdenliveSettings::setMltpath(profilePath);
#ifdef Q_OS_WIN
......@@ -60,9 +66,15 @@ void MltConnection::locateMeltAndProfilesPath(const QString &mltPath)
#else
QString exeSuffix = "";
#endif
QString meltPath = qgetenv("MLT_PREFIX") + QStringLiteral("/bin/melt") + exeSuffix;
if (!QFile::exists(meltPath)) meltPath = QDir::cleanPath(profilePath + QStringLiteral("../../../bin/melt") + exeSuffix);
if (!QFile::exists(meltPath)) meltPath = QStandardPaths::findExecutable("melt");
QString meltPath;
if (qEnvironmentVariableIsSet("MLT_PREFIX"))
meltPath = qgetenv("MLT_PREFIX") + QStringLiteral("/bin/melt") + exeSuffix;
if (!QFile::exists(meltPath)) {
meltPath = QDir::cleanPath(profilePath + QStringLiteral("/../../../bin/melt")) + exeSuffix;
}
if (!QFile::exists(meltPath)) {
meltPath = QStandardPaths::findExecutable("melt");
}
KdenliveSettings::setRendererpath(meltPath);
if (meltPath.isEmpty()) {
......@@ -82,7 +94,7 @@ void MltConnection::locateMeltAndProfilesPath(const QString &mltPath)
}
}
if (profilePath.isEmpty()) {
profilePath = QDir::cleanPath(meltPath + QStringLiteral("/../../share/mlt/profiles/"));
profilePath = QDir::cleanPath(meltPath + QStringLiteral("/../../share/mlt/profiles"));
KdenliveSettings::setMltpath(profilePath);
}
QStringList profilesFilter;
......@@ -92,9 +104,9 @@ void MltConnection::locateMeltAndProfilesPath(const QString &mltPath)
// Cannot find MLT path, try finding melt
if (!meltPath.isEmpty()) {
if(meltPath.contains(QLatin1Char('/'))) {
profilePath = meltPath.section(QLatin1Char('/'), 0, -2) + QStringLiteral("/share/mlt/profiles/");
profilePath = meltPath.section(QLatin1Char('/'), 0, -2) + QStringLiteral("/share/mlt/profiles");
} else {
profilePath = qApp->applicationDirPath() + QStringLiteral("/share/mlt/profiles/");
profilePath = qApp->applicationDirPath() + QStringLiteral("/share/mlt/profiles");
}
KdenliveSettings::setMltpath(profilePath);
profilesList = QDir(profilePath).entryList(profilesFilter, QDir::Files);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment