File labtool_dfu-util_permissions.patch of Package labtool

From 97506648e04f13957487ef43b529196ab9c0bb9f Mon Sep 17 00:00:00 2001
From: Scott Tsai <scottt.tw@gmail.com>
Date: Sun, 14 Sep 2014 05:59:17 +0800
Subject: [PATCH 1/3] LabToolDeviceCommThread: avoid zombie processes if
 dfu-tool isn't executable

See https://bugreports.qt-project.org/browse/QTBUG-5990
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.
---
 app/device/labtool/labtooldevicecommthread.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/app/device/labtool/labtooldevicecommthread.cpp b/app/device/labtool/labtooldevicecommthread.cpp
index 69d308a..ee2b019 100644
--- a/app/device/labtool/labtooldevicecommthread.cpp
+++ b/app/device/labtool/labtooldevicecommthread.cpp
@@ -19,6 +19,7 @@
 #include <QTime>
 #include <stdio.h>
 #include <QCoreApplication>
+#include <QDebug>
 
 /*!
     \class LabToolDeviceCommThread
@@ -221,6 +222,14 @@ void LabToolDeviceCommThread::runDFU()
         program = "../" + program;
     }
 #endif
+    // Test that 'program' is executable before executing it to avoid zombie processes, see
+    // https://bugreports.qt-project.org/browse/QTBUG-5990
+    if (!(QFile::permissions(program) & QFile::ExeUser))
+    {
+        qCritical() << "Please change the permssion on \"" << program << "\" to make it executable";
+        return;
+    }
+
     QStringList arguments;
     arguments << "-R" << "-d 1fc9:000c" << "-D" << mPreparedImage;
     //mDFUProcess->setWorkingDirectory("../tools/dfu-util-0.7-binaries/win32-mingw32/");
-- 
2.1.4

openSUSE Build Service is sponsored by