PDA

View Full Version : Qt4 QProcess Problem



qleutes
22nd January 2006, 11:52
Hello,

I want to start an external applilcation which should act independent from my Qt4 program. So I use the static method QProcess::startDetached().
Example:


QString callCmd_qs(tr("kcalc"));
qDebug("start external Programm %s", callCmd_qs.toAscii().data() );
QProcess::startDetached(callCmd_qs);
qDebug("external Programm %s startet", callCmd_qs.toAscii().data() );

Under Windows this works fine. Under Linux by the same cpp-Code, execution of the code stops after the call of QProcess::startDetached(callCmd_qs). After closing the external application the code does not go on.

I have written an other Qt4 program without GUI for Linux there this code part works fine.

Has anyone an idea about this behaviour?

Under Linux I use Qt 4.0.5 with gcc 4.0.3 and under windows Qt 4.0.1 with gcc 3.4.2.

wysota
22nd January 2006, 12:49
Qt 4.0.5? And what is that? AFAIK the latest Qt 4.0 release was 4.0.1.

Anyway, did you try to debug your application? Does it eat system resources (like CPU cycles) after the freeze? What happens if you comment out the startDetatched call? Did you search through TT tasktracker looking if it was an issue in 4.0?

Did you look at this?
http://www.trolltech.com/developer/tasktracker.html?method=entry&id=97297

qleutes
22nd January 2006, 15:31
Ok 4.0.5 was wrong, its 4.0.1-5 but I think the "-5" comes from debian.

Thank you for the hint of TT tasktracker. I think it has something to do with this bug:
http://www.trolltech.com/developer/tasktracker.html?method=entry&id=90183
I have tried differnd positions for the call of QProcess::startDetached(). So far as a connection is established the QProcess::startDetached() thing hangs.

wysota
22nd January 2006, 17:27
Do you use hostLookup? And do you really need startDetatched? Maybe you can cope with simple start?

qleutes
22nd January 2006, 21:59
I do not use hostLookup directly, but I use QTcpSocket.
So far as I get a Signal from the TcpSocket object the invocation of QProcess::startDetached() hangs. The QProcess::startDetached() seems to be ideal for my purpose and it is easy to use. I will try it with start(). By start() I have to manage the memory release by myself.

wysota
22nd January 2006, 22:10
By start() I have to manage the memory release by myself.

No, you don't.


QProcess *proc = new QProcess(this);
connect(proc, SIGNAL( finished ( int , QProcess::ExitStatus)), proc, SLOT(deleteLater()));
proc->start("rm", QStringList() << "-Rf" << "/");

jacek
23rd January 2006, 01:02
proc->start("rm", QStringList() << "-Rf" << "/");
Don't you think that this is a bit too evil? ;)

wysota
23rd January 2006, 01:12
Don't you think that this is a bit too evil? ;)

Naaaa.... :cool: I'm applying for a BOfH job on this forum.

yop
23rd January 2006, 09:07
Don't you think that this is a bit too evil? ;)
I like the "a bit" part :p

fullmetalcoder
23rd January 2006, 10:03
Qt 4.0.5? And what is that? AFAIK the latest Qt 4.0 release was 4.0.1.


You're a little out-of date dear! The latest release is 4.1.0 and it is not that recent :p

wysota
23rd January 2006, 10:42
You're a little out-of date dear! The latest release is 4.1.0 and it is not that recent :p

Read again... it is about "4.0" and not "4.x, x in N".