The following piece of code starts a process that takes one second to finish, and subsequently waits for that process to finish before exiting. For some reason, the following code hangs in p->waitForFinished()
even though the process did finish.
#include <QtCore/QProcess>
class A
{
public:
A():
p(0)
{
}
~A()
{
p->waitForFinished();
delete p;
}
void start()
{
p = new QProcess(0);
p->start("sleep 1");
}
QProcess *p;
};
int main(void)
{
static A a;
a.start();
return 0;
}
However, as soon as a
is not declared statically, but as follows:
A a;
the waitForFinished()
call succeeds. Is this a Qt bug, or is this expected behavour? My suspicion is that some kind of logic required to detect whether an application successfully finished is already destroyed once the destructor of A
is called.