Commit 1ab9ec4c authored by Mads Bondo Dydensborg's avatar Mads Bondo Dydensborg

Proposed solution to issue 0000345: Capture inigo error to log or screen...

Proposed solution to issue 0000345: Capture inigo error to log or screen (http://www.kdenlive.org/mantis/view.php?id=345) - adds some more debugging output, and logs command line arguments and westley content to log file in temporary directory. I believe we need something like this to help out the users that does not get anything rendered. There is no integration with the GUI though, and since I am unable to get avformat to complain, I don't know if all errors are collected. Please note that I reindented the files before committing, and that the commit is much larger than the changes due to this.

svn path=/branches/KDE4/; revision=2810
parent d0a7184b
......@@ -48,7 +48,7 @@ int main(int argc, char **argv) {
}
if (args.at(0).startsWith("preargs=")) {
QString a = args.at(0).section('=', 1);
preargs = a.split(" ", QString::SkipEmptyParts);
preargs = a.split(" ", QString::SkipEmptyParts);
args.takeFirst();
}
QString render = args.at(0);
......@@ -63,9 +63,9 @@ int main(int argc, char **argv) {
args.takeFirst();
QString dest = args.at(0);
args.takeFirst();
qDebug() << "//STARTING RENDERING: " << erase << "," << render << "," << profile << "," << rendermodule << "," << player << "," << src << "," << dest << "," << preargs << "," << args << "," << in << "," << out;
RenderJob *job = new RenderJob(erase, render, profile, rendermodule, player, src, dest, preargs, args, in, out);
job->start();
qDebug()<<"//STARTING RENDERING: "<<erase<<","<<render<<","<<profile<<","<<rendermodule<<","<<player<<","<<src<<","<<dest<<","<<preargs<<","<<args<<","<<in<<","<<out;
app.exec();
} else {
fprintf(stderr, "Kdenlive video renderer for MLT.\nUsage: "
......
......@@ -22,14 +22,14 @@
#include <QThread>
#include "renderjob.h"
// Can't believe I need to do this to sleep.
class SleepThread : QThread {
public:
virtual void run() {};
static void msleep(unsigned long msecs) {
QThread::msleep(msecs);
}
};
// Can't believe I need to do this to sleep.
class SleepThread : QThread {
public:
virtual void run() {};
static void msleep(unsigned long msecs) {
QThread::msleep(msecs);
}
};
static QDBusConnection connection(QLatin1String(""));
......@@ -50,11 +50,31 @@ RenderJob::RenderJob(bool erase, const QString &renderer, const QString &profile
m_args << "-consumer" << rendermodule + ":" + m_dest << "progress=1" << args;
connect(m_renderProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotIsOver(int, QProcess::ExitStatus)));
m_renderProcess->setReadChannel(QProcess::StandardError);
// Create a log of every render process.
m_logfile.setAutoRemove(false);
m_logfile.setFileTemplate(QDir::tempPath() + "/kdenlive_render.log.XXXXXXXX");
if (m_logfile.open()) {
qDebug() << "Writing render log to " << m_logfile.fileName();
} else {
qDebug() << "Unable to log to " << m_logfile.fileName();
}
m_logstream.setDevice(&m_logfile);
m_logstream << "Log starting. Dumping contents of " << scenelist << endl;
QFile file(scenelist);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
m_logstream << "Unable to read contents of " << scenelist << endl;
} else {
m_logstream.flush();
QTextStream in(&file);
m_logstream << in.readAll() << endl;
}
}
RenderJob::~RenderJob() {
if (m_renderProcess) delete m_renderProcess;
m_logfile.close();
}
void RenderJob::slotAbort() {
......@@ -67,56 +87,66 @@ void RenderJob::slotAbort() {
}
QFile f(m_dest);
f.remove();
m_logstream << "Job aborted by user" << endl;
m_logstream.flush();
m_logfile.close();
qApp->quit();
}
void RenderJob::receivedStderr() {
QString result = QString(m_renderProcess->readAllStandardError()).simplified();
m_logstream << "ReceivedStderr from inigo: " << result << endl;
result = result.section(" ", -1);
int pro = result.toInt();
if (pro > m_progress) {
if ( m_jobUiserver && pro > m_progress) {
m_progress = pro;
m_jobUiserver->call("setPercent", (uint) m_progress);
int seconds = m_startTime.secsTo(QTime::currentTime());
seconds = seconds * (100 - m_progress) / m_progress;
m_jobUiserver->call("setDescriptionField", (uint) 1, tr("Remaining time"), QTime(0, 0, seconds).toString("hh:mm:ss"));
m_jobUiserver->call("setPercent", (uint) m_progress);
int seconds = m_startTime.secsTo(QTime::currentTime());
seconds = seconds * (100 - m_progress) / m_progress;
m_jobUiserver->call("setDescriptionField", (uint) 1, tr("Remaining time"), QTime(0, 0, seconds).toString("hh:mm:ss"));
}
}
void RenderJob::start() {
QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
if (interface) {
if (!interface->isServiceRegistered("org.kde.JobViewServer")) {
qDebug() << "No org.kde.JobViewServer registered, trying to start kuiserver";
if ( QProcess::startDetached( "kuiserver" ) ) {
qDebug() << "Started kuiserver";
// Give it a couple of seconds to start
QTime t;
t.start();
while ( !interface->isServiceRegistered("org.kde.JobViewServer") && t.elapsed() < 3000 ) {
SleepThread::msleep( 100 ); //Sleep 100 ms
}
} else {
qDebug() << "Failed to start kuiserver";
}
}
if (interface->isServiceRegistered("org.kde.JobViewServer")) {
QDBusInterface kuiserver("org.kde.JobViewServer", "/JobViewServer", "org.kde.JobViewServer");
QDBusReply<QDBusObjectPath> objectPath = kuiserver.call("requestView", "kdenlive", "kdenlive", 1);
QString reply = ((QDBusObjectPath) objectPath).path();
m_jobUiserver = new QDBusInterface("org.kde.JobViewServer", reply, "org.kde.JobView");
if (m_jobUiserver) {
m_startTime = QTime::currentTime();
m_jobUiserver->call("setPercent", (uint) 0);
QDBusReply<QString> reply = m_jobUiserver->call("setInfoMessage", tr("Rendering %1").arg(QFileInfo(m_dest).fileName()));
m_jobUiserver->call("setDescriptionField", (uint) 0, tr("Rendering to"), m_dest);
QDBusConnection::sessionBus().connect("org.kde.JobViewServer", reply, "org.kde.JobView", "cancelRequested", this, SLOT(slotAbort()));
connect(m_renderProcess, SIGNAL(readyReadStandardError()), this, SLOT(receivedStderr()));
}
}
if (!interface->isServiceRegistered("org.kde.JobViewServer")) {
qDebug() << "No org.kde.JobViewServer registered, trying to start kuiserver";
m_logstream << "No org.kde.JobViewServer registered, trying to start kuiserver";
if (QProcess::startDetached("kuiserver")) {
qDebug() << "Started kuiserver";
m_logstream << "Started kuiserver";
// Give it a couple of seconds to start
QTime t;
t.start();
while (!interface->isServiceRegistered("org.kde.JobViewServer") && t.elapsed() < 3000) {
SleepThread::msleep(100); //Sleep 100 ms
}
} else {
qDebug() << "Failed to start kuiserver";
m_logstream << "Failed to start kuiserver";
}
}
if (interface->isServiceRegistered("org.kde.JobViewServer")) {
QDBusInterface kuiserver("org.kde.JobViewServer", "/JobViewServer", "org.kde.JobViewServer");
QDBusReply<QDBusObjectPath> objectPath = kuiserver.call("requestView", "kdenlive", "kdenlive", 1);
QString reply = ((QDBusObjectPath) objectPath).path();
m_jobUiserver = new QDBusInterface("org.kde.JobViewServer", reply, "org.kde.JobView");
if (m_jobUiserver) {
m_startTime = QTime::currentTime();
m_jobUiserver->call("setPercent", (uint) 0);
QDBusReply<QString> reply = m_jobUiserver->call("setInfoMessage", tr("Rendering %1").arg(QFileInfo(m_dest).fileName()));
m_jobUiserver->call("setDescriptionField", (uint) 0, tr("Rendering to"), m_dest);
QDBusConnection::sessionBus().connect("org.kde.JobViewServer", reply, "org.kde.JobView", "cancelRequested", this, SLOT(slotAbort()));
}
}
}
// Because of the logging, we connect to stderr in all cases.
connect(m_renderProcess, SIGNAL(readyReadStandardError()), this, SLOT(receivedStderr()));
m_renderProcess->start(m_prog, m_args);
m_logstream << "Started render process: " << m_prog << " " << m_args.join(" ") << endl;
qDebug() << "Started render process: " << m_prog << " " << m_args.join(" ");
}
......@@ -130,31 +160,35 @@ void RenderJob::slotIsOver(int exitcode, QProcess::ExitStatus status) {
// rendering crashed
QStringList args;
args << "--error" << tr("Rendering of %1 aborted, resulting video will probably be corrupted.").arg(m_dest);
m_logstream << "Rendering of " << m_dest << " aborted, resulting video will probably be corrupted." << endl;
qDebug() << "Rendering of " << m_dest << " aborted, resulting video will probably be corrupted.";
QProcess::startDetached("kdialog", args);
} else {
QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
if (interface && interface->isServiceRegistered("org.kde.knotify")) {
QDBusMessage m = QDBusMessage::createMethodCall("org.kde.knotify",
QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
if (interface && interface->isServiceRegistered("org.kde.knotify")) {
QDBusMessage m = QDBusMessage::createMethodCall("org.kde.knotify",
"/Notify",
"org.kde.KNotify",
"event");
int seconds = m_startTime.secsTo(QTime::currentTime());
QList<QVariant> args;
args.append(QString("RenderFinished")); // action name
args.append(QString("kdenlive")); // app name
args.append(QVariantList()); // contexts
args.append(tr("Rendering of %1 finished in %2").arg(m_dest, QTime(0, 0, seconds).toString("hh:mm:ss"))); // body
args.append(QByteArray()); // app icon
QStringList actionList;
args.append(actionList); // actions
qlonglong wid;
args.append(wid); // win id
m.setArguments(args);
QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m);
}
int seconds = m_startTime.secsTo(QTime::currentTime());
QList<QVariant> args;
args.append(QString("RenderFinished")); // action name
args.append(QString("kdenlive")); // app name
args.append(QVariantList()); // contexts
args.append(tr("Rendering of %1 finished in %2").arg(m_dest, QTime(0, 0, seconds).toString("hh:mm:ss"))); // body
args.append(QByteArray()); // app icon
QStringList actionList;
args.append(actionList); // actions
qlonglong wid;
args.append(wid); // win id
m.setArguments(args);
QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m);
}
m_logstream << "Rendering of " << m_dest << " finished" << endl;
qDebug() << "Rendering of " << m_dest << " finished";
if (m_player != "-") {
m_logstream << "Starting player" << endl;
QStringList args;
args << m_dest;
QProcess::startDetached(m_player, args);
......
......@@ -25,6 +25,9 @@
#include <QObject>
#include <QDBusInterface>
#include <QTime>
// Testing
#include <QTemporaryFile>
#include <QTextStream>
class RenderJob : public QObject {
Q_OBJECT
......@@ -49,6 +52,10 @@ private:
bool m_erase;
QDBusInterface *m_jobUiserver;
QTime m_startTime;
/** \brief Used to create a temporary file for logging */
QTemporaryFile m_logfile;
/** \brief Used to write to the log file */
QTextStream m_logstream;
};
#endif
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