diff ui/mainwindow.cpp @ 563:aee3eb10bbba

Add unit test for sw update execution and fix shell execute params
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 22 May 2014 15:18:06 +0000
parents 4cc378f335f5
children ebfe1128ee97 02a89710a7cd
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Thu May 22 15:29:59 2014 +0200
+++ b/ui/mainwindow.cpp	Thu May 22 15:18:06 2014 +0000
@@ -14,6 +14,7 @@
 #include <QSystemTrayIcon>
 #include <QAction>
 #include <QDialog>
+#include <QDir>
 #include <QMenu>
 #include <QApplication>
 #include <QFile>
@@ -149,7 +150,6 @@
             mSettings.remove("List/installedDate");
         }
     } else {
-        // Make sure the available notation is also removed
         mSettings.remove("List/installed");
         mSettings.remove("List/installedDate");
     }
@@ -201,10 +201,15 @@
         setState(TransferError);
         return;
     }
+    QString filePath = QDir::toNativeSeparators(instProcInfo.absoluteFilePath());
 #ifdef WIN32
     SHELLEXECUTEINFOW shExecInfo;
-    shExecInfo.lpFile = reinterpret_cast<LPCWSTR> (
-            QDir::toNativeSeparators(instProcInfo.absoluteFilePath()).utf16());
+    memset (&shExecInfo, 0, sizeof(SHELLEXECUTEINFOW));
+    shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
+
+    shExecInfo.lpFile = reinterpret_cast<LPCWSTR> (filePath.utf16());
+
+    shExecInfo.fMask = SEE_MASK_NOASYNC;
 
     if (!is_admin()) {
         shExecInfo.lpVerb = L"open";
@@ -212,8 +217,7 @@
         shExecInfo.lpVerb = L"runas";
     }
 
-    qDebug() << "Admin? " << is_admin();
-    qDebug() << "Starting processs: " << QDir::toNativeSeparators(instProcInfo.absoluteFilePath());
+    qDebug() << "Starting process: " << filePath;
 
     if (!ShellExecuteExW(&shExecInfo)) {
         /* Execution failed, maybe the user aborted the UAC check? */
@@ -224,15 +228,10 @@
         setState(NewSoftwareAvailable);
         return;
     }
-
 #else /* WIN32 */
-    QProcess installerProcess;
-    installerProcess.setProgram(fileName);
+    qDebug() << "Starting process " << filePath;
 
-    qDebug() << "Starting process " << fileName;
-
-    if (!installerProcess.waitForStarted() ||
-        installerProcess.state() == QProcess::NotRunning) {
+    if (!QProcess::startDetached(filePath)) {
         qDebug() << "Failed to start process.";
         return;
     }

http://wald.intevation.org/projects/trustbridge/