]> git.lyx.org Git - features.git/commitdiff
Read standard output and error upon completion. And properly close the channels befor...
authorAbdelrazak Younes <younes@lyx.org>
Mon, 11 May 2009 11:51:52 +0000 (11:51 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 11 May 2009 11:51:52 +0000 (11:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29628 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/Systemcall.cpp

index 24548b66479df24c2ecf4c69e9f174c0f0672ac5..3d01683c96b8dfa765baed8724ae7817a326ce4a 100644 (file)
@@ -19,6 +19,7 @@
 #include "support/os.h"
 
 #include <cstdlib>
+#include <iostream>
 
 #include <QProcess>
 
@@ -29,6 +30,15 @@ using namespace std;
 namespace lyx {
 namespace support {
 
+static void killProcess(QProcess * p)
+{
+       p->closeReadChannel(QProcess::StandardOutput);
+       p->closeReadChannel(QProcess::StandardError);
+       p->close();
+       delete p;
+}
+
+
 // Reuse of instance
 int Systemcall::startscript(Starttype how, string const & what)
 {
@@ -50,6 +60,8 @@ int Systemcall::startscript(Starttype how, string const & what)
 #else
        QString cmd = QString::fromLocal8Bit(what.c_str());
        QProcess * process = new QProcess;
+       cmd.replace("python", "python2.5");
+       cmd.prepend("/usr/bin/");
        process->start(cmd);
        if (!process->waitForStarted(1000)) {
                LYXERR0("Qprocess " << cmd << " did not start!");
@@ -76,7 +88,9 @@ int Systemcall::startscript(Starttype how, string const & what)
                LYXERR0("state " << process->state());
                LYXERR0("status " << process->exitStatus());
        }
-       delete process;
+       cout << fromqstr(QString::fromLocal8Bit(process->readAllStandardOutput().data())) << endl;
+       cerr << fromqstr(QString::fromLocal8Bit(process->readAllStandardError().data())) << endl;
+       killProcess(process);
        return exit_code;
 #endif
 }