Bug in QProcess::stateChanged

This bug is easy to replicate and it’s been present for a long time. In fact, this bug report was sent in 2013 and still waits to be fixed.

If you have a QProcess and you use the QProcess::stateChanged signal to check when the process goes down, do not try to restart the process in the slot attached to the signal because the QProcess state will get stuck in QProcess::Starting and it won’t work.

Instead, restart your process in a slot connected to the QProcess::finished signal, or use QTimer::singleShot within the handler of stateChanged to enqueue the process restart instead of doing it immediately.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.