Commit 64e6bdfc authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Ensure processes are in the path before starting an executable

parent cfc8ce20
Pipeline #131835 passed with stage
in 7 minutes and 6 seconds
......@@ -310,7 +310,7 @@ RenderWidget::RenderWidget(bool enableProxy, QWidget *parent)
if (!QFile::exists(m_renderer)) {
m_renderer = QStandardPaths::findExecutable(QStringLiteral("kdenlive_render"));
if (m_renderer.isEmpty()) {
m_renderer = QStringLiteral("kdenlive_render");
KMessageBox::sorry(this, i18n("Could not find the kdenlive_render application, something is wrong with your installation. Rendering will not work"));
}
}
......
......@@ -1545,65 +1545,69 @@ void ClipPropertiesController::slotFillMeta(QTreeWidget *tree)
// Check for Canon THM file
url = url.section(QLatin1Char('.'), 0, -2) + QStringLiteral(".THM");
if (QFile::exists(url)) {
// Read the exif metadata embedded in the THM file
QProcess p;
QStringList args;
args << QStringLiteral("-g") << QStringLiteral("-args") << url;
p.start(QStringLiteral("exiftool"), args);
p.waitForFinished();
QString res = p.readAllStandardOutput();
m_controller->setProducerProperty(QStringLiteral("kdenlive:exiftool"), 1);
QTreeWidgetItem *exif = nullptr;
QStringList list = res.split(QLatin1Char('\n'));
for (const QString &tagline : qAsConst(list)) {
if (tagline.startsWith(QLatin1String("-File")) || tagline.startsWith(QLatin1String("-ExifTool"))) {
continue;
}
QString tag = tagline.section(QLatin1Char(':'), 1).simplified();
if (tag.startsWith(QLatin1String("ImageWidth")) || tag.startsWith(QLatin1String("ImageHeight"))) {
continue;
}
if (!tag.section(QLatin1Char('='), 0, 0).isEmpty() && !tag.section(QLatin1Char('='), 1).simplified().isEmpty()) {
if (!exif) {
exif = new QTreeWidgetItem(tree, QStringList() << i18n("Exif") << QString());
exif->setExpanded(true);
}
m_controller->setProducerProperty("kdenlive:meta.exiftool." + tag.section(QLatin1Char('='), 0, 0),
tag.section(QLatin1Char('='), 1).simplified());
new QTreeWidgetItem(exif, QStringList() << tag.section(QLatin1Char('='), 0, 0) << tag.section(QLatin1Char('='), 1).simplified());
}
}
} else {
if (m_type == ClipType::Image || m_controller->codec(false) == QLatin1String("h264")) {
QString exifToolBinary = QStandardPaths::findExecutable(QStringLiteral("exiftool"));
if (!exifToolBinary.isEmpty()) {
// Read the exif metadata embedded in the THM file
QProcess p;
QStringList args;
args << QStringLiteral("-g") << QStringLiteral("-args") << m_controller->clipUrl();
p.start(QStringLiteral("exiftool"), args);
QStringList args = {QStringLiteral("-g"), QStringLiteral("-args"), url};
p.start(exifToolBinary, args);
p.waitForFinished();
QString res = p.readAllStandardOutput();
if (m_type != ClipType::Image) {
m_controller->setProducerProperty(QStringLiteral("kdenlive:exiftool"), 1);
}
m_controller->setProducerProperty(QStringLiteral("kdenlive:exiftool"), 1);
QTreeWidgetItem *exif = nullptr;
QStringList list = res.split(QLatin1Char('\n'));
for (const QString &tagline : qAsConst(list)) {
if (m_type != ClipType::Image && !tagline.startsWith(QLatin1String("-H264"))) {
if (tagline.startsWith(QLatin1String("-File")) || tagline.startsWith(QLatin1String("-ExifTool"))) {
continue;
}
QString tag = tagline.section(QLatin1Char(':'), 1);
QString tag = tagline.section(QLatin1Char(':'), 1).simplified();
if (tag.startsWith(QLatin1String("ImageWidth")) || tag.startsWith(QLatin1String("ImageHeight"))) {
continue;
}
if (!exif) {
exif = new QTreeWidgetItem(tree, QStringList() << i18n("Exif") << QString());
exif->setExpanded(true);
if (!tag.section(QLatin1Char('='), 0, 0).isEmpty() && !tag.section(QLatin1Char('='), 1).simplified().isEmpty()) {
if (!exif) {
exif = new QTreeWidgetItem(tree, QStringList() << i18n("Exif") << QString());
exif->setExpanded(true);
}
m_controller->setProducerProperty("kdenlive:meta.exiftool." + tag.section(QLatin1Char('='), 0, 0),
tag.section(QLatin1Char('='), 1).simplified());
new QTreeWidgetItem(exif, QStringList() << tag.section(QLatin1Char('='), 0, 0) << tag.section(QLatin1Char('='), 1).simplified());
}
}
}
} else {
if (m_type == ClipType::Image || m_controller->codec(false) == QLatin1String("h264")) {
QString exifToolBinary = QStandardPaths::findExecutable(QStringLiteral("exiftool"));
if (!exifToolBinary.isEmpty()) {
QProcess p;
QStringList args = {QStringLiteral("-g"), QStringLiteral("-args"), m_controller->clipUrl()};
p.start(exifToolBinary, args);
p.waitForFinished();
QString res = p.readAllStandardOutput();
if (m_type != ClipType::Image) {
// Do not store image exif metadata in project file, would be too much noise
m_controller->setProducerProperty("kdenlive:meta.exiftool." + tag.section(QLatin1Char('='), 0, 0),
m_controller->setProducerProperty(QStringLiteral("kdenlive:exiftool"), 1);
}
QTreeWidgetItem *exif = nullptr;
QStringList list = res.split(QLatin1Char('\n'));
for (const QString &tagline : qAsConst(list)) {
if (m_type != ClipType::Image && !tagline.startsWith(QLatin1String("-H264"))) {
continue;
}
QString tag = tagline.section(QLatin1Char(':'), 1);
if (tag.startsWith(QLatin1String("ImageWidth")) || tag.startsWith(QLatin1String("ImageHeight"))) {
continue;
}
if (!exif) {
exif = new QTreeWidgetItem(tree, QStringList() << i18n("Exif") << QString());
exif->setExpanded(true);
}
if (m_type != ClipType::Image) {
// Do not store image exif metadata in project file, would be too much noise
m_controller->setProducerProperty("kdenlive:meta.exiftool." + tag.section(QLatin1Char('='), 0, 0),
tag.section(QLatin1Char('='), 1).simplified());
}
new QTreeWidgetItem(exif, QStringList() << tag.section(QLatin1Char('='), 0, 0) << tag.section(QLatin1Char('='), 1).simplified());
}
new QTreeWidgetItem(exif, QStringList() << tag.section(QLatin1Char('='), 0, 0) << tag.section(QLatin1Char('='), 1).simplified());
}
}
}
......
......@@ -89,7 +89,12 @@ bool OtioConvertions::configureSetup()
bool OtioConvertions::runOtioconvert(const QString &inputFile, const QString &outputFile) {
QProcess convert;
convert.start(QStringLiteral("otioconvert"), {"-i", inputFile, "-o", outputFile});
QString otioBinary = QStandardPaths::findExecutable(QStringLiteral("otioconvert"));
if (otioBinary.isEmpty()) {
KMessageBox::sorry(pCore->window(), i18n("OpenTimelineIO Application otioconvert not found"));
return false;
}
convert.start(otioBinary, {"-i", inputFile, "-o", outputFile});
convert.waitForFinished();
if(convert.exitStatus() != QProcess::NormalExit || convert.exitCode() != 0) {
KMessageBox::detailedError(pCore->window(), i18n("OpenTimelineIO Project conversion failed"),
......
......@@ -16,6 +16,7 @@
#include "timeline2/view/timelinewidget.h"
#include <KLocalizedString>
#include <KMessageBox>
#include <QCollator>
#include <QProcess>
#include <QMutexLocker>
......@@ -45,7 +46,7 @@ PreviewManager::PreviewManager(TimelineController *controller, Mlt::Tractor *tra
if (!QFile::exists(m_renderer)) {
m_renderer = QStandardPaths::findExecutable(QStringLiteral("kdenlive_render"));
if (m_renderer.isEmpty()) {
m_renderer = QStringLiteral("kdenlive_render");
KMessageBox::sorry(pCore->window(), i18n("Could not find the kdenlive_render application, something is wrong with your installation. Rendering will not work"));
}
}
connect(this, &PreviewManager::abortPreview, &m_previewProcess, &QProcess::kill, Qt::DirectConnection);
......
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