embeddedartists/labtool — pull request #5 by scottt (2014-09-13 22:24:45+00:00)
Title: Launch dfu util fix

The first patch avoids zombie processes if dfu-tool isn't executable. Otherwise leaving LabTool running with the hardware disconnected (I do that do stare at the waveform) will eventually "fork-bomb" POSIX systems by exhausting the number of processes a user is allowed to have.

See https://bugreports.qt-project.org/browse/QTBUG-5990 for background. Qt has this bug where if the executable passed to QProcess.start() somehow fails to start, it could leave zombie processes around even if the user calls WaitForStarted() and WaitForFinished() correctly. This patch works around a common source of this bug by checking the permission of the "dfu-util" executable before attempting to execute it.

The second patch in the series makes the path handling in LabToolDeviceCommThread::prepareDfuImage() more consistant with ::runDFU() and allow launching LabTool from "./app/LabTool", i.e. one directory level up.

The third patch is a minor clean up. From the QProcess state machine design it's more correct to call ::WaitForStarted() and not call ::WaitForFinished() if the former fails. This patch also make "DFUProcess" a local variable instead of a pointer to heap allocate object to make forgoetting to call delete on error paths impossible.