Utils: Remove qPidToPid() adapter function

Since Qt 5.3, there's a QProcess::processId() providing direct access.

Change-Id: Ia9c143c7a92ec61d1aa36ff3f4670ba72a509634
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
hjk
2015-09-11 13:13:04 +02:00
parent 1a8faab311
commit 77661e378a
18 changed files with 25 additions and 39 deletions

View File

@@ -1487,16 +1487,6 @@ void QtcProcess::ArgIterator::appendArg(const QString &str)
m_pos += qstr.length() + 1; m_pos += qstr.length() + 1;
} }
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
}
QtcProcess::Arguments QtcProcess::Arguments::createWindowsArgs(const QString &args) QtcProcess::Arguments QtcProcess::Arguments::createWindowsArgs(const QString &args)
{ {
Arguments result; Arguments result;

View File

@@ -157,10 +157,6 @@ private:
bool m_useCtrlCStub; bool m_useCtrlCStub;
}; };
// 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 } // namespace Utils
#endif // QTCPROCESS_H #endif // QTCPROCESS_H

View File

@@ -67,7 +67,7 @@ void GdbServerProviderProcess::start(const QString &executable, const QStringLis
void GdbServerProviderProcess::interrupt() void GdbServerProviderProcess::interrupt()
{ {
device()->signalOperation()->interruptProcess(Utils::qPidToPid(m_process->pid())); device()->signalOperation()->interruptProcess(m_process->processId());
} }
void GdbServerProviderProcess::terminate() void GdbServerProviderProcess::terminate()

View File

@@ -640,7 +640,7 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
return false; return false;
} }
const unsigned long pid = Utils::qPidToPid(m_process.pid()); const qint64 pid = m_process.processId();
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

@@ -50,7 +50,7 @@ namespace Debugger {
// Do not add anything that needs implementation in a .cpp file. // Do not add anything that needs implementation in a .cpp file.
const int InvalidPort = -1; const int InvalidPort = -1;
const int InvalidPid = -1; const qint64 InvalidPid = -1;
class DEBUGGER_EXPORT RemoteSetupResult class DEBUGGER_EXPORT RemoteSetupResult
{ {
@@ -64,7 +64,7 @@ public:
int gdbServerPort; int gdbServerPort;
int qmlServerPort; int qmlServerPort;
int inferiorPid; qint64 inferiorPid;
bool success; bool success;
QString reason; QString reason;
}; };

View File

@@ -438,7 +438,7 @@ void GdbRemoteServerEngine::interruptInferior2()
} else if (m_isQnxGdb && HostOsInfo::isWindowsHost()) { } else if (m_isQnxGdb && HostOsInfo::isWindowsHost()) {
m_gdbProc.interrupt(); m_gdbProc.interrupt();
} else { } else {
long pid = Utils::qPidToPid(m_gdbProc.pid()); qint64 pid = m_gdbProc.processId();
bool ok = interruptProcess(pid, GdbEngineType, &m_errorString); bool ok = interruptProcess(pid, GdbEngineType, &m_errorString);
if (!ok) { if (!ok) {
// FIXME: Extra state needed? // FIXME: Extra state needed?

View File

@@ -37,7 +37,7 @@
using namespace Debugger::Internal; using namespace Debugger::Internal;
static inline QString msgCannotInterrupt(int pid, const QString &why) static inline QString msgCannotInterrupt(qint64 pid, const QString &why)
{ {
return QString::fromLatin1("Cannot interrupt process %1: %2").arg(pid).arg(why); return QString::fromLatin1("Cannot interrupt process %1: %2").arg(pid).arg(why);
} }
@@ -80,7 +80,7 @@ static BOOL isWow64Process(HANDLE hproc)
} }
// Open the process and break into it // Open the process and break into it
bool Debugger::Internal::interruptProcess(int pID, int engineType, QString *errorMessage, const bool engineExecutableIs64Bit) bool Debugger::Internal::interruptProcess(qint64 pID, int engineType, QString *errorMessage, const bool engineExecutableIs64Bit)
{ {
bool ok = false; bool ok = false;
HANDLE inferior = NULL; HANDLE inferior = NULL;
@@ -88,7 +88,7 @@ bool Debugger::Internal::interruptProcess(int pID, int engineType, QString *erro
const DWORD rights = PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION const DWORD rights = PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION
|PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ |PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ
|PROCESS_DUP_HANDLE|PROCESS_TERMINATE|PROCESS_CREATE_THREAD|PROCESS_SUSPEND_RESUME; |PROCESS_DUP_HANDLE|PROCESS_TERMINATE|PROCESS_CREATE_THREAD|PROCESS_SUSPEND_RESUME;
inferior = OpenProcess(rights, FALSE, pID); inferior = OpenProcess(rights, FALSE, DWORD(pID));
if (inferior == NULL) { if (inferior == NULL) {
*errorMessage = QString::fromLatin1("Cannot open process %1: %2"). *errorMessage = QString::fromLatin1("Cannot open process %1: %2").
arg(pID).arg(Utils::winErrorMessage(GetLastError())); arg(pID).arg(Utils::winErrorMessage(GetLastError()));
@@ -188,7 +188,7 @@ GDB 32bit | Api | Api | NA | Win32
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
bool Debugger::Internal::interruptProcess(int pID, int /* engineType */, bool Debugger::Internal::interruptProcess(qint64 pID, int /* engineType */,
QString *errorMessage, const bool /*engineExecutableIs64Bit*/) QString *errorMessage, const bool /*engineExecutableIs64Bit*/)
{ {
if (pID <= 0) { if (pID <= 0) {

View File

@@ -36,7 +36,7 @@
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
bool interruptProcess(int pID, int engineType, QString *errorMessage, bool interruptProcess(qint64 pID, int engineType, QString *errorMessage,
const bool engineExecutableIs64Bit = false); const bool engineExecutableIs64Bit = false);
} // Internal } // Internal

View File

@@ -138,7 +138,7 @@ void IosAnalyzeSupport::handleServerPorts(int gdbServerPort, int qmlPort)
m_qmlPort = qmlPort; m_qmlPort = qmlPort;
} }
void IosAnalyzeSupport::handleGotInferiorPid(Q_PID pid, int qmlPort) void IosAnalyzeSupport::handleGotInferiorPid(qint64 pid, int qmlPort)
{ {
Q_UNUSED(pid); Q_UNUSED(pid);
m_qmlPort = qmlPort; m_qmlPort = qmlPort;

View File

@@ -60,7 +60,7 @@ public:
private: private:
void qmlServerReady(); void qmlServerReady();
void handleServerPorts(int gdbServerFd, int qmlPort); void handleServerPorts(int gdbServerFd, int qmlPort);
void handleGotInferiorPid(Q_PID, int qmlPort); void handleGotInferiorPid(qint64 pid, int qmlPort);
void handleRemoteProcessFinished(bool cleanEnd); void handleRemoteProcessFinished(bool cleanEnd);
void handleRemoteOutput(const QString &output); void handleRemoteOutput(const QString &output);

View File

@@ -197,11 +197,11 @@ void IosDebugSupport::handleServerPorts(int gdbServerPort, int qmlPort)
m_runControl->notifyEngineRemoteSetupFinished(result); m_runControl->notifyEngineRemoteSetupFinished(result);
} }
void IosDebugSupport::handleGotInferiorPid(Q_PID pid, int qmlPort) void IosDebugSupport::handleGotInferiorPid(qint64 pid, int qmlPort)
{ {
RemoteSetupResult result; RemoteSetupResult result;
result.qmlServerPort = qmlPort; result.qmlServerPort = qmlPort;
result.inferiorPid = int(Utils::qPidToPid(pid)); result.inferiorPid = pid;
result.success = pid > 0; result.success = pid > 0;
if (!result.success) if (!result.success)
result.reason = tr("Got an invalid process id."); result.reason = tr("Got an invalid process id.");

View File

@@ -56,7 +56,7 @@ public:
private: private:
void handleServerPorts(int gdbServerFd, int qmlPort); void handleServerPorts(int gdbServerFd, int qmlPort);
void handleGotInferiorPid(Q_PID, int qmlPort); void handleGotInferiorPid(qint64, int qmlPort);
void handleRemoteProcessFinished(bool cleanEnd); void handleRemoteProcessFinished(bool cleanEnd);
void handleRemoteOutput(const QString &output); void handleRemoteOutput(const QString &output);

View File

@@ -191,7 +191,7 @@ void IosRunner::handleGotServerPorts(IosToolHandler *handler, const QString &bun
} }
void IosRunner::handleGotInferiorPid(IosToolHandler *handler, const QString &bundlePath, void IosRunner::handleGotInferiorPid(IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, Q_PID pid) const QString &deviceId, qint64 pid)
{ {
Q_UNUSED(bundlePath); Q_UNUSED(deviceId); Q_UNUSED(bundlePath); Q_UNUSED(deviceId);
m_pid = pid; m_pid = pid;

View File

@@ -72,7 +72,7 @@ public slots:
signals: signals:
void didStartApp(Ios::IosToolHandler::OpStatus status); void didStartApp(Ios::IosToolHandler::OpStatus status);
void gotServerPorts(int gdbPort, int qmlPort); void gotServerPorts(int gdbPort, int qmlPort);
void gotInferiorPid(Q_PID pid, int); void gotInferiorPid(qint64 pid, int);
void appOutput(const QString &output); void appOutput(const QString &output);
void errorMsg(const QString &msg); void errorMsg(const QString &msg);
void finished(bool cleanExit); void finished(bool cleanExit);
@@ -83,7 +83,7 @@ private:
void handleGotServerPorts(Ios::IosToolHandler *handler, const QString &bundlePath, void handleGotServerPorts(Ios::IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, int gdbPort, int qmlPort); const QString &deviceId, int gdbPort, int qmlPort);
void handleGotInferiorPid(Ios::IosToolHandler *handler, const QString &bundlePath, void handleGotInferiorPid(Ios::IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, Q_PID pid); const QString &deviceId, qint64 pid);
void handleAppOutput(Ios::IosToolHandler *handler, const QString &output); void handleAppOutput(Ios::IosToolHandler *handler, const QString &output);
void handleErrorMsg(Ios::IosToolHandler *handler, const QString &msg); void handleErrorMsg(Ios::IosToolHandler *handler, const QString &msg);
void handleToolExited(Ios::IosToolHandler *handler, int code); void handleToolExited(Ios::IosToolHandler *handler, int code);
@@ -99,7 +99,7 @@ private:
bool m_cleanExit; bool m_cleanExit;
quint16 m_qmlPort; quint16 m_qmlPort;
Q_PID m_pid; qint64 m_pid;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -148,7 +148,7 @@ public:
IosToolHandler::OpStatus status); IosToolHandler::OpStatus status);
void gotServerPorts(const QString &bundlePath, const QString &deviceId, int gdbPort, void gotServerPorts(const QString &bundlePath, const QString &deviceId, int gdbPort,
int qmlPort); int qmlPort);
void gotInferiorPid(const QString &bundlePath, const QString &deviceId, Q_PID pid); void gotInferiorPid(const QString &bundlePath, const QString &deviceId, qint64 pid);
void deviceInfo(const QString &deviceId, const IosToolHandler::Dict &info); void deviceInfo(const QString &deviceId, const IosToolHandler::Dict &info);
void appOutput(const QString &output); void appOutput(const QString &output);
void errorMsg(const QString &msg); void errorMsg(const QString &msg);
@@ -318,7 +318,7 @@ void IosToolHandlerPrivate::gotServerPorts(const QString &bundlePath,
} }
void IosToolHandlerPrivate::gotInferiorPid(const QString &bundlePath, const QString &deviceId, void IosToolHandlerPrivate::gotInferiorPid(const QString &bundlePath, const QString &deviceId,
Q_PID pid) qint64 pid)
{ {
emit q->gotInferiorPid(q, bundlePath, deviceId, pid); emit q->gotInferiorPid(q, bundlePath, deviceId, pid);
} }
@@ -504,7 +504,7 @@ void IosToolHandlerPrivate::processXml()
case ParserState::Exit: case ParserState::Exit:
break; break;
case ParserState::InferiorPid: case ParserState::InferiorPid:
gotInferiorPid(bundlePath, deviceId, Q_PID(p.chars.toInt())); gotInferiorPid(bundlePath, deviceId, p.chars.toLongLong());
break; break;
case ParserState::ServerPorts: case ParserState::ServerPorts:
break; break;

View File

@@ -80,7 +80,7 @@ signals:
void gotServerPorts(Ios::IosToolHandler *handler, const QString &bundlePath, void gotServerPorts(Ios::IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, int gdbPort, int qmlPort); const QString &deviceId, int gdbPort, int qmlPort);
void gotInferiorPid(Ios::IosToolHandler *handler, const QString &bundlePath, void gotInferiorPid(Ios::IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, Q_PID pid); const QString &deviceId, qint64 pid);
void deviceInfo(Ios::IosToolHandler *handler, const QString &deviceId, void deviceInfo(Ios::IosToolHandler *handler, const QString &deviceId,
const Ios::IosToolHandler::Dict &info); const Ios::IosToolHandler::Dict &info);
void appOutput(Ios::IosToolHandler *handler, const QString &output); void appOutput(Ios::IosToolHandler *handler, const QString &output);

View File

@@ -212,7 +212,7 @@ qint64 ApplicationLauncher::applicationPID() const
if (d->m_currentMode == Console) if (d->m_currentMode == Console)
return d->m_consoleProcess.applicationPID(); return d->m_consoleProcess.applicationPID();
else else
return Utils::qPidToPid(d->m_guiProcess.pid()); return d->m_guiProcess.processId();
} }
QString ApplicationLauncher::errorString() const QString ApplicationLauncher::errorString() const

View File

@@ -58,7 +58,7 @@ void DesktopDeviceProcess::start(const QString &executable, const QStringList &a
void DesktopDeviceProcess::interrupt() void DesktopDeviceProcess::interrupt()
{ {
device()->signalOperation()->interruptProcess(Utils::qPidToPid(m_process->pid())); device()->signalOperation()->interruptProcess(m_process->processId());
} }
void DesktopDeviceProcess::terminate() void DesktopDeviceProcess::terminate()