Manually emiting errorOcurred
-
I am trying to build an scheduler for running several
QProcess
's in parallel. The executable I am trying to run rarely crashes, but when it does it already handles the divergent cases itself, such thatQProcess
always sends finished signals withNormalExit
status. However, my program must be able to handle these error cases. For that, I connect two slots to the finished signal.The first slot reads the standard output of the program, and checks for error messages. If it finds any match, it will emit an
errorOcurred
singal with aCrashed
status.The second slots handles the finishing signal. In all cases, the next process in the queue starts. But now I want to send a signal telling the user that a process has finished with
Crashed
. However, I cannot do this because the processes always finish withNormalExit
, and even when emitting theerrorOcurred
signal in the first slot, trying to recover theCrashed
status in the second signal is not possible because when callingerror()
on the signalsender()
I getUnknownError
instead ofCrashed
.Does anybody know how to update the processes
ProcessError
value manually? -
@oarcelus
Qt at least does not document a way for user to setProcessError
manually, so you can't (unless you find some way examining the source code).Your situation is complicated. But in a word it sounds like you should "wrap" your
QProcess
calls/return results and emit your own signal, perhaps with your own setProcessError
value or other indication to detect whatever your desired situation is. -
@JonB Hi, thanks for answering, yes I thought about some custom signals with a
QProcess
subclass. But then this would assume that the process scheduler knows the specific details about the subclass and it loses a bit of generality. In any case, it looks like this is the way. Thanks again.