Frage

I have a problem running phantomjs.exe binary in my QProcess class. Consider this code:

QString program = "phantomjs.exe";
QProcess *process = new QProcess(this);
process->start(program, QStringList() << "test.js");

When I start the app main process loads up and nothing happens after that, just hundreds of other phantomjs.exe are created (checking it in TaskManager) as well as conhost.exe processes.

I tried other exe files, like notepad.exe, and it works just fine. Notepad window appears.

Did you encounter this problem?

War es hilfreich?

Lösung 2

After checking I found that there is a problem with QProcess. I used SHELLEXECUTEINFO instead. This code works for me well. No recursive calls of phantomjs.exe here:

SHELLEXECUTEINFO shExecInfo;
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);

shExecInfo.fMask = NULL;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = L"runas";
shExecInfo.lpFile = L"phantomjs.exe";
shExecInfo.lpParameters = L"test.js";
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_NORMAL;
shExecInfo.hInstApp = NULL;

ShellExecuteEx(&shExecInfo);

Andere Tipps

Do you call phantom.exit() in your test script?

https://github.com/ariya/phantomjs/wiki/Quick-Start

console.log('Hello, world!');
phantom.exit();

Hope that helps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top