[PATCH 2 of 6] Style: run astyle on processhelp
Wald Commits
scm-commit at wald.intevation.org
Wed Jun 18 14:41:30 CEST 2014
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1403082310 -7200
# Node ID 91dd38a717834f95af233113c682211bd410e31f
# Parent 1642a79cc02d031a2db73b56bf0d8f19f045ff99
Style: run astyle on processhelp
diff -r 1642a79cc02d -r 91dd38a71783 ui/processhelp.h
--- a/ui/processhelp.h Wed Jun 18 10:44:39 2014 +0200
+++ b/ui/processhelp.h Wed Jun 18 11:05:10 2014 +0200
@@ -19,30 +19,31 @@
* @brief process handling functions
*/
-namespace ProcessHelp {
- /**
- * @brief look up process id's for a processName
- *
- * Looks up processes run by the current user.
- *
- * @param[in] processName the name of the process to look for
- * @returns a list of pids that match this process. May be empty
- */
- const QList<int> getProcessesIdForName(const QString &processName);
+namespace ProcessHelp
+{
+/**
+* @brief look up process id's for a processName
+*
+* Looks up processes run by the current user.
+*
+* @param[in] processName the name of the process to look for
+* @returns a list of pids that match this process. May be empty
+*/
+const QList<int> getProcessesIdForName(const QString &processName);
- /**
- * @brief check if another process with the same name exists
- *
- * @param[in] processName name of the process to look for.
- *
- * @returns true if one or more processes (other than the current process) exist
- */
- bool otherProcessesExist(const QString &processName);
+/**
+* @brief check if another process with the same name exists
+*
+* @param[in] processName name of the process to look for.
+*
+* @returns true if one or more processes (other than the current process) exist
+*/
+bool otherProcessesExist(const QString &processName);
- /**
- * @brief Activates the window for first found process
- * @param [in] executableName executableName (without path and .exe extension)
- */
- void activateWindowForProcess(const QString &executableName);
+/**
+* @brief Activates the window for first found process
+* @param [in] executableName executableName (without path and .exe extension)
+*/
+void activateWindowForProcess(const QString &executableName);
}
#endif // PROCESSHELP_H
diff -r 1642a79cc02d -r 91dd38a71783 ui/processhelp_win.cpp
--- a/ui/processhelp_win.cpp Wed Jun 18 10:44:39 2014 +0200
+++ b/ui/processhelp_win.cpp Wed Jun 18 11:05:10 2014 +0200
@@ -16,21 +16,20 @@
#include <QDebug>
-struct EnumWindowsStruct
-{
- EnumWindowsStruct() : windowId( 0 ) {}
- DWORD pid;
- HWND windowId;
+struct EnumWindowsStruct {
+ EnumWindowsStruct() : windowId(0) {}
+ DWORD pid;
+ HWND windowId;
};
PSID copySid(PSID from)
{
- if ( !from ) {
+ if (!from) {
return 0;
}
- int sidLength = GetLengthSid( from );
- PSID to = (PSID) xmalloc( sidLength );
+ int sidLength = GetLengthSid(from);
+ PSID to = (PSID) xmalloc(sidLength);
CopySid(sidLength, to, from);
return to;
}
@@ -41,18 +40,18 @@
PSID sid;
OpenProcessToken(hProcess, TOKEN_READ, &hToken);
- if ( hToken ) {
+ if (hToken) {
DWORD size;
PTOKEN_USER userStruct;
// check how much space is needed
- GetTokenInformation( hToken, TokenUser, NULL, 0, &size );
- if ( ERROR_INSUFFICIENT_BUFFER == GetLastError() ) {
- userStruct = reinterpret_cast<PTOKEN_USER>( new BYTE[size] );
- GetTokenInformation( hToken, TokenUser, userStruct, size, &size );
+ GetTokenInformation(hToken, TokenUser, NULL, 0, &size);
+ if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) {
+ userStruct = reinterpret_cast<PTOKEN_USER>(new BYTE[size]);
+ GetTokenInformation(hToken, TokenUser, userStruct, size, &size);
- sid = copySid( userStruct->User.Sid );
- CloseHandle( hToken );
+ sid = copySid(userStruct->User.Sid);
+ CloseHandle(hToken);
delete [] userStruct;
return sid;
}
@@ -104,19 +103,19 @@
pids.clear();
do {
- if ( QString::fromWCharArray(pe32.szExeFile) == processName ) {
+ if (QString::fromWCharArray(pe32.szExeFile) == processName) {
PSID user_sid = getProcessOwner(GetCurrentProcess());
- if ( user_sid ) {
+ if (user_sid) {
// Also check that we are the owner of that process
HANDLE hProcess = getProcessHandle(pe32.th32ProcessID);
- if ( !hProcess ) {
+ if (!hProcess) {
continue;
}
PSID sid = getProcessOwner(hProcess);
PSID userSid = getProcessOwner(GetCurrentProcess());
- if ( !sid || (userSid && !EqualSid(userSid, sid))) {
- free (sid);
+ if (!sid || (userSid && !EqualSid(userSid, sid))) {
+ free(sid);
continue;
}
}
@@ -124,7 +123,7 @@
qDebug() << "found PID: " << (int)pe32.th32ProcessID;
}
} while (Process32Next(h, &pe32));
- CloseHandle( h );
+ CloseHandle(h);
return pids;
}
@@ -132,7 +131,7 @@
{
const QList<int> pids = getProcessesIdForName(processName);
int myPid = getpid();
- foreach (int pid, pids) {
+ foreach(int pid, pids) {
if (myPid != pid) {
qDebug() << "Found another process with id: " << pid;
return true;
@@ -141,27 +140,28 @@
return false;
}
-void ProcessHelp::activateWindowForProcess(const QString &executableName) {
+void ProcessHelp::activateWindowForProcess(const QString &executableName)
+{
const QList<int> pids = getProcessesIdForName(executableName);
int myPid = getpid();
int foundPid = 0;
- foreach (int pid, pids) {
+ foreach(int pid, pids) {
if (myPid != pid) {
qDebug() << "activateWindowForProcess(): PID to activate:" << pid;
foundPid = pid;
break;
}
}
- if ( foundPid == 0 ) {
+ if (foundPid == 0) {
return;
}
EnumWindowsStruct winStruct;
winStruct.pid = foundPid;
- EnumWindows( EnumWindowsProc, (LPARAM)&winStruct );
- if ( winStruct.windowId == 0 ) {
+ EnumWindows(EnumWindowsProc, (LPARAM)&winStruct);
+ if (winStruct.windowId == 0) {
return;
}
- SetForegroundWindow( winStruct.windowId );
+ SetForegroundWindow(winStruct.windowId);
}
#endif // WIN32
More information about the Trustbridge-commits
mailing list