StartDetached and Process ID issues
-
So I finally managed to run a process and quit launcher automatically when process quits. However, when process was running with start(), launcher was frozen. So I figured if I run process detached, then launcher won't be frozen. Sure enough, that works.
Here is my code: http://pastebin.com/v8Y6zeEt
However, the issue is that launcher no longer receives signals from the process. So when process quits, launcher still runs. What am I doing wrong ?
Thanks!
EDIT: Perhaps I don't need to run detached process. I just need for launcher not to be frozen when process is running.
-
Hi,
Several wrong things here:
- startDetached is static function -> Don't create a QProcess to use it
- you are creating memory leaks
Each time you call executeGameBinary or shutdownLauncherBinary you create a new QProcess without even destroying the old one. But that's not the most important since it's the wrong approach to your problem.
waitForFinished is what is blocking your UI.
Please look again at the Fluid Launcher example, the usage of QProcess shown there is exactly what you need.
-
[quote author="SGaist" date="1405410957"]Hi,
Each time you call executeGameBinary or shutdownLauncherBinary you create a new QProcess without even destroying the old one. But that's not the most important since it's the wrong approach to your problem.[/quote]What would be the correct approach?
executeGameBinary or shutdownLauncherBinary are called only once - starting the game and quitting launcher. They can't be called more than once (or at least they shouldn't by design, since the game can be launched only once).
Perhaps I should disable Start and Quit buttons when the process is running, and minimize launcher (or hide it). Are there any examples how to do that?
[quote author="SGaist" date="1405410957"]waitForFinished is what is blocking your UI.[/quote]
I see. Basically it's looping, waiting for process to shut down?
[quote author="SGaist" date="1405410957"]Please look again at the Fluid Launcher example, the usage of QProcess shown there is exactly what you need.[/quote]
Looked. Seems like I need to figure out slots and signals and connect().
Thanks.