Project hangs on QProcess::start when starting QtAssistant

248 views Asked by At

I am using QProcess::start to launch Qt Assistant with my custom help project file. It works fine until i load project(not help project file) to my programm. Programm generates images from specific data using custom library. Even when all processes ends and i see generated images and nothing else happens, when i trying to launch Qt Assistant, my programm hangs at QProcess:start function when trying to start process. The code is:

show() function(public):

if (!run())
    return false;
QByteArray ba("setSource ");
ba.append("qthelp://insyn_help/doc/");

proc->write(ba + page.toLocal8Bit() + '\n');
return true;

run() function(private):

if (!proc)
    proc = new QProcess();
if (proc->state() == QProcess::Running)
    return true;
QString app = QString(QT_BIN_DIR) + QDir::separator() + QString("assistant");
QString path = QString(PREFIX) + QString(HELP_INSTALL_PATH) + QString("/help_project.qhc");
QStringList args;
args << QLatin1String("-collectionFile")
     << QLatin1String(path.toLatin1())
     << QLatin1String("-enableRemoteControl");

QFileInfo help_project(path);
if (help_project.exists()) {
    proc->start(app,args);
    if (!proc->waitForStarted()) {
        m_exitCode = 1;
        emit closed();
        return false;
    }
}

This code is a part of AssistantLauncher class which was registered using qmlRegisterType and added to main.qml as a member of application window. My programm doesn't touch it anywhere (except calling a method show()). It is separate object (except it is a part of appWindow). The question is why does the process can not start only after my programm did some work? And why QProcess::start even dont have timeout.

UPD: I moved proc->start(app,args); to the child process, which i getting by using fork() and now my programm hangs on pid_t child = fork(). So the problem is that new process can not be created.

1

There are 1 answers

0
Maxim Skvortsov On BEST ANSWER

The answer is to do not use fork() because it is dangerous in big projects. More at http://www.evanjones.ca/fork-is-dangerous.html . posix_spawn also hangs my project. Now i decided to fork() new process at the beginning and send commands to it through the pipe.