summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2012-10-25 12:53:53 +0200
committerKarsten Heimrich <karsten.heimrich@digia.com>2012-10-25 17:46:07 +0200
commit2a73db7e34bd2a9f61455aad73df68294dd1b22c (patch)
tree657826d340340538a13aa43b6e885044a862bc60 /src/libs
parent528bca1008fa268fe200ac0dbad9ff06f9ea3c08 (diff)
Fix freeze after rejecting UAC account (check GetLastError()).
Fixes too the case with runing a shared build. Since the environment is not shared, we would not be able to load missing libs, thus failing to start the server and endless loop the wait for the servers connection. Change-Id: If4c50783eb86488b3c2e0a92357750d9c17e7750 Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/adminauthorization_win.cpp53
-rw-r--r--src/libs/installer/fsengineclient.cpp11
2 files changed, 33 insertions, 31 deletions
diff --git a/src/libs/installer/adminauthorization_win.cpp b/src/libs/installer/adminauthorization_win.cpp
index ce6d20a4e..d9de7c728 100644
--- a/src/libs/installer/adminauthorization_win.cpp
+++ b/src/libs/installer/adminauthorization_win.cpp
@@ -33,13 +33,25 @@
#include "utils.h"
-#include <QtCore/QDebug>
-#include <QtCore/QDir>
-#include <QtCore/QStringList>
-#include <QtCore/QVector>
+#include <QDebug>
+#include <QDir>
#include <windows.h>
+struct DeCoInitializer
+{
+ DeCoInitializer()
+ : neededCoInit(CoInitialize(NULL) == S_OK)
+ {
+ }
+ ~DeCoInitializer()
+ {
+ if (neededCoInit)
+ CoUninitialize();
+ }
+ bool neededCoInit;
+};
+
AdminAuthorization::AdminAuthorization()
{
}
@@ -74,30 +86,21 @@ bool AdminAuthorization::hasAdminRights()
bool AdminAuthorization::execute(QWidget *, const QString &program, const QStringList &arguments)
{
+ DeCoInitializer _;
+
const QString file = QDir::toNativeSeparators(program);
const QString args = QInstaller::createCommandline(QString(), arguments);
- const int len = GetShortPathName((wchar_t *)file.utf16(), 0, 0);
- if (len == 0)
- return false;
- wchar_t *const buffer = new wchar_t[len];
- GetShortPathName((wchar_t *)file.utf16(), buffer, len);
+ SHELLEXECUTEINFOW shellExecuteInfo = { 0 };
+ shellExecuteInfo.nShow = SW_HIDE;
+ shellExecuteInfo.lpVerb = L"runas";
+ shellExecuteInfo.lpFile = (wchar_t *)file.utf16();
+ shellExecuteInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
+ shellExecuteInfo.lpParameters = (wchar_t *)args.utf16();
- SHELLEXECUTEINFOW TempInfo = { 0 };
- TempInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
- TempInfo.fMask = 0;
- TempInfo.hwnd = 0;
- TempInfo.lpVerb = L"runas";
- TempInfo.lpFile = buffer;
- TempInfo.lpParameters = (wchar_t *)args.utf16();
- TempInfo.lpDirectory = 0;
- TempInfo.nShow = SW_NORMAL;
+ qDebug() << QString::fromLatin1("Starting elevated process %1 with arguments: %2.").arg(file, args);
+ ShellExecuteExW(&shellExecuteInfo);
+ qDebug() << "Finished starting elevated process.";
-
- qDebug() << QString::fromLatin1(" starting elevated process %1 %2 with ::ShellExecuteExW( &TempInfo );"
- ).arg(program, arguments.join(QLatin1String(" ")));
- const bool result = ::ShellExecuteEx(&TempInfo);
- qDebug() << QLatin1String("after starting elevated process");
- delete[] buffer;
- return result;
+ return GetLastError() == ERROR_SUCCESS;
}
diff --git a/src/libs/installer/fsengineclient.cpp b/src/libs/installer/fsengineclient.cpp
index 3221b9f29..7e3ceb1d5 100644
--- a/src/libs/installer/fsengineclient.cpp
+++ b/src/libs/installer/fsengineclient.cpp
@@ -783,7 +783,8 @@ void FSEngineClientHandler::Private::maybeStartServer()
if (!serverStarted) {
// something went wrong with authorizing, either user pressed cancel or entered
// wrong password
- const QString fallback = serverCommand + QLatin1String(" ") + serverArguments.join(QLatin1String(" "));
+ const QString fallback = serverCommand + QLatin1String(" ") + serverArguments
+ .join(QLatin1String(" "));
const QMessageBox::Button res =
QInstaller::MessageBoxHandler::critical(QInstaller::MessageBoxHandler::currentBestSuitParent(),
@@ -800,11 +801,9 @@ void FSEngineClientHandler::Private::maybeStartServer()
serverStarted = QProcess::startDetached(serverCommand, serverArguments);
}
- // now wait for the socket to arrive
- QTcpSocket s;
- while (serverStarting && serverStarted) {
- if (FSEngineClientHandler::instance().connect(&s))
- serverStarting = false;
+ if (serverStarted) {
+ QTcpSocket s; // now wait for the socket to arrive
+ serverStarted = FSEngineClientHandler::instance().connect(&s);
}
serverStarting = false;
}