Slightly safer check of rendering job termination

svn path=/trunk/kdenlive/; revision=3627
parent 694d7a50
......@@ -45,7 +45,7 @@ RenderJob::RenderJob(bool erase, bool usekuiserver, const QString &renderer, con
m_jobUiserver(NULL),
m_kdenliveinterface(NULL),
m_usekuiserver(usekuiserver),
m_enablelog( false )
m_enablelog(false)
{
m_scenelist = scenelist;
m_dest = dest;
......@@ -69,26 +69,27 @@ RenderJob::RenderJob(bool erase, bool usekuiserver, const QString &renderer, con
m_dualpass = false;
if (args.contains("pass=1")) m_dualpass = true;
connect(m_renderProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotIsOver(int, QProcess::ExitStatus)));
connect(m_renderProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(slotCheckProcess(QProcess::ProcessState)));
//connect(m_renderProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotIsOver(int, QProcess::ExitStatus)));
m_renderProcess->setReadChannel(QProcess::StandardError);
m_enablelog = ( getenv( "KDENLIVE_RENDER_LOG" ) != NULL );
if ( m_enablelog ) {
m_enablelog = (getenv("KDENLIVE_RENDER_LOG") != NULL);
if (m_enablelog) {
// 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);
QString tmplist = scenelist;
if ( tmplist.contains( "consumer:" ) ) {
QStringList tl = tmplist.split( "consumer:" );
if ( tl.count() == 2 ) {
tmplist = tl[1];
if (tmplist.contains("consumer:")) {
QStringList tl = tmplist.split("consumer:");
if (tl.count() == 2) {
tmplist = tl[1];
}
}
m_logstream << "Log starting. Dumping contents of " << tmplist << endl;
......@@ -107,7 +108,7 @@ RenderJob::RenderJob(bool erase, bool usekuiserver, const QString &renderer, con
RenderJob::~RenderJob()
{
if (m_renderProcess) delete m_renderProcess;
if ( m_enablelog ) {
if (m_enablelog) {
m_logfile.close();
}
}
......@@ -134,7 +135,7 @@ void RenderJob::slotAbort()
}
QFile f(m_dest);
f.remove();
if ( m_enablelog ) {
if (m_enablelog) {
m_logstream << "Job aborted by user" << endl;
m_logstream.flush();
m_logfile.close();
......@@ -147,7 +148,7 @@ void RenderJob::receivedStderr()
QString result = QString(m_renderProcess->readAllStandardError()).simplified();
if (!result.startsWith("Current Frame")) m_errorMessage.append(result + "<br>");
else {
if ( m_enablelog ) m_logstream << "ReceivedStderr from melt: " << result << endl;
if (m_enablelog) m_logstream << "ReceivedStderr from melt: " << result << endl;
result = result.section(' ', -1);
int pro = result.toInt();
if (pro < 0 || pro > 100) return;
......@@ -184,10 +185,10 @@ void RenderJob::start()
if (interface && m_usekuiserver) {
if (!interface->isServiceRegistered("org.kde.JobViewServer")) {
qDebug() << "No org.kde.JobViewServer registered, trying to start kuiserver";
if ( m_enablelog ) m_logstream << "No org.kde.JobViewServer registered, trying to start kuiserver";
if (m_enablelog) m_logstream << "No org.kde.JobViewServer registered, trying to start kuiserver";
if (QProcess::startDetached("kuiserver")) {
qDebug() << "Started kuiserver";
if ( m_enablelog ) m_logstream << "Started kuiserver";
if (m_enablelog) m_logstream << "Started kuiserver";
// Give it a couple of seconds to start
QTime t;
t.start();
......@@ -196,7 +197,7 @@ void RenderJob::start()
}
} else {
qDebug() << "Failed to start kuiserver";
if ( m_enablelog ) m_logstream << "Failed to start kuiserver";
if (m_enablelog) m_logstream << "Failed to start kuiserver";
}
}
......@@ -220,7 +221,7 @@ void RenderJob::start()
// 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);
if ( m_enablelog ) m_logstream << "Started render process: " << m_prog << " " << m_args.join(" ") << endl;
if (m_enablelog) m_logstream << "Started render process: " << m_prog << " " << m_args.join(" ") << endl;
qDebug() << "Started render process: " << m_prog << " " << m_args.join(" ");
}
......@@ -255,14 +256,21 @@ void RenderJob::initKdenliveDbusInterface()
}
void RenderJob::slotIsOver(int /*exitcode*/, QProcess::ExitStatus status)
void RenderJob::slotCheckProcess(QProcess::ProcessState state)
{
if (state == QProcess::NotRunning) slotIsOver(m_renderProcess->exitStatus());
}
void RenderJob::slotIsOver(QProcess::ExitStatus status)
{
if (m_jobUiserver) m_jobUiserver->call("terminate", QString());
if (m_erase) {
QFile f(m_scenelist);
f.remove();
}
if (status == QProcess::CrashExit) {
if (status == QProcess::CrashExit || m_renderProcess->error() != QProcess::UnknownError) {
// rendering crashed
if (m_kdenliveinterface) {
m_dbusargs[1] = (int) - 2;
......@@ -271,7 +279,7 @@ void RenderJob::slotIsOver(int /*exitcode*/, QProcess::ExitStatus status)
}
QStringList args;
args << "--error" << tr("Rendering of %1 aborted, resulting video will probably be corrupted.").arg(m_dest);
if ( m_enablelog ) m_logstream << "Rendering of " << m_dest << " aborted, resulting video will probably be corrupted." << endl;
if (m_enablelog) 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);
qApp->quit();
......@@ -302,10 +310,10 @@ void RenderJob::slotIsOver(int /*exitcode*/, QProcess::ExitStatus status)
m.setArguments(args);
QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m);
}
if ( m_enablelog ) m_logstream << "Rendering of " << m_dest << " finished" << endl;
if (m_enablelog) m_logstream << "Rendering of " << m_dest << " finished" << endl;
qDebug() << "Rendering of " << m_dest << " finished";
if (!m_dualpass && m_player != "-") {
if ( m_enablelog ) m_logstream << "Starting player" << endl;
if (m_enablelog) m_logstream << "Starting player" << endl;
QStringList args;
args << m_dest;
QProcess::startDetached(m_player, args);
......
......@@ -41,10 +41,11 @@ public slots:
void start();
private slots:
void slotIsOver(int exitcode, QProcess::ExitStatus status);
void slotIsOver(QProcess::ExitStatus status);
void receivedStderr();
void slotAbort();
void slotAbort(const QString& url);
void slotCheckProcess(QProcess::ProcessState state);
private:
QString m_scenelist;
......
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