Utils: Rename winQPidToPid to qPidToPid

... and make it a no-op on non-Windows. Saves #ifdefs.

Change-Id: Ie791f7b9f1a425325d0b889e73758c5f7f7e6ad2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
hjk
2013-07-12 09:00:12 +02:00
parent 80e657b390
commit b89afac9d4
7 changed files with 26 additions and 26 deletions

View File

@@ -1473,3 +1473,17 @@ void QtcProcess::ArgIterator::appendArg(const QString &str)
m_str->insert(m_pos, QLatin1Char(' ') + qstr); m_str->insert(m_pos, QLatin1Char(' ') + qstr);
m_pos += qstr.length() + 1; m_pos += qstr.length() + 1;
} }
namespace Utils {
QTCREATOR_UTILS_EXPORT unsigned long qPidToPid(const Q_PID qpid)
{
#ifdef Q_OS_WIN
const PROCESS_INFORMATION *processInfo = reinterpret_cast<const PROCESS_INFORMATION*>(qpid);
return processInfo->dwProcessId;
#else
return qpid;
#endif
}
} // namespace Utils

View File

@@ -155,6 +155,10 @@ private:
#endif #endif
}; };
} // Converts the Q_PID into a integer value. This is a no-op
// except on Windows.
QTCREATOR_UTILS_EXPORT unsigned long qPidToPid(const Q_PID qpid);
} // namespace Utils
#endif // QTCPROCESS_H #endif // QTCPROCESS_H

View File

@@ -177,12 +177,6 @@ QTCREATOR_UTILS_EXPORT QString normalizePathName(const QString &name)
return canonicalName; return canonicalName;
} }
QTCREATOR_UTILS_EXPORT unsigned long winQPidToPid(const Q_PID qpid)
{
const PROCESS_INFORMATION *processInfo = reinterpret_cast<const PROCESS_INFORMATION*>(qpid);
return processInfo->dwProcessId;
}
QTCREATOR_UTILS_EXPORT bool winIs64BitSystem() QTCREATOR_UTILS_EXPORT bool winIs64BitSystem()
{ {
SYSTEM_INFO systemInfo; SYSTEM_INFO systemInfo;

View File

@@ -59,6 +59,8 @@ QTCREATOR_UTILS_EXPORT QString getLongPathName(const QString &name);
// Returns long name with canonical capitalization. // Returns long name with canonical capitalization.
QTCREATOR_UTILS_EXPORT QString normalizePathName(const QString &name); QTCREATOR_UTILS_EXPORT QString normalizePathName(const QString &name);
// Converts the Q_PID into a integer value. This is a no-op
// except on Windows.
QTCREATOR_UTILS_EXPORT unsigned long winQPidToPid(const Q_PID qpid); QTCREATOR_UTILS_EXPORT unsigned long winQPidToPid(const Q_PID qpid);
QTCREATOR_UTILS_EXPORT bool winIs64BitSystem(); QTCREATOR_UTILS_EXPORT bool winIs64BitSystem();

View File

@@ -754,11 +754,8 @@ bool CdbEngine::launchCDB(const DebuggerStartParameters &sp, QString *errorMessa
arg(QDir::toNativeSeparators(executable), m_process.errorString()); arg(QDir::toNativeSeparators(executable), m_process.errorString());
return false; return false;
} }
#ifdef Q_OS_WIN
const unsigned long pid = Utils::winQPidToPid(m_process.pid()); const unsigned long pid = Utils::qPidToPid(m_process.pid());
#else
const unsigned long pid = 0;
#endif
showMessage(QString::fromLatin1("%1 running as %2"). showMessage(QString::fromLatin1("%1 running as %2").
arg(QDir::toNativeSeparators(executable)).arg(pid), LogMisc); arg(QDir::toNativeSeparators(executable)).arg(pid), LogMisc);
m_hasDebuggee = true; m_hasDebuggee = true;

View File

@@ -32,9 +32,7 @@
#include "procinterrupt.h" #include "procinterrupt.h"
#include "debuggerconstants.h" #include "debuggerconstants.h"
#ifdef Q_OS_WIN #include <utils/qtcprocess.h>
#include <utils/winutils.h>
#endif
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -84,12 +82,7 @@ void LocalGdbProcess::kill()
bool LocalGdbProcess::interrupt() bool LocalGdbProcess::interrupt()
{ {
long pid; long pid = Utils::qPidToPid(m_gdbProc.pid());
#ifdef Q_OS_WIN
pid = Utils::winQPidToPid(m_gdbProc.pid());
#else
pid = m_gdbProc.pid();
#endif
return interruptProcess(pid, GdbEngineType, &m_errorString); return interruptProcess(pid, GdbEngineType, &m_errorString);
} }

View File

@@ -135,11 +135,7 @@ void ValgrindProcess::run(const QString &valgrindExecutable, const QStringList &
m_localProcess.setCommand(valgrindExecutable, m_arguments); m_localProcess.setCommand(valgrindExecutable, m_arguments);
m_localProcess.start(); m_localProcess.start();
m_localProcess.waitForStarted(); m_localProcess.waitForStarted();
#ifdef Q_OS_WIN m_pid = Utils::qPidToPid(m_localProcess.pid());
m_pid = Utils::winQPidToPid(m_localProcess.pid());
#else
m_pid = m_localProcess.pid();
#endif
} else { } else {
m_remote.m_valgrindExe = valgrindExecutable; m_remote.m_valgrindExe = valgrindExecutable;
m_remote.m_debuggee = debuggeeExecutable; m_remote.m_debuggee = debuggeeExecutable;