summaryrefslogtreecommitdiff
path: root/src/shared/trk
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-10-23 18:19:53 +0200
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-10-23 18:19:53 +0200
commit1c528c48ccb11403f01c9e60145e0f99609ba815 (patch)
tree4513ced3f19f54df0b0b144c63d3381af800d5ab /src/shared/trk
parent1af61fefa8f22932cc0db0559782ec11b0e39fd0 (diff)
downloadqt-creator-1c528c48ccb11403f01c9e60145e0f99609ba815.tar.gz
Fix compilation on Windows
Diffstat (limited to 'src/shared/trk')
-rw-r--r--src/shared/trk/bluetoothlistener.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/shared/trk/bluetoothlistener.cpp b/src/shared/trk/bluetoothlistener.cpp
index b395131ad3..6b22dea6d4 100644
--- a/src/shared/trk/bluetoothlistener.cpp
+++ b/src/shared/trk/bluetoothlistener.cpp
@@ -37,8 +37,26 @@
#ifdef Q_OS_UNIX
# include <unistd.h>
# include <signal.h>
+#else
+# include <windows.h>
#endif
+// Process id helpers.
+#ifdef Q_OS_WIN
+inline DWORD processId(const QProcess &p)
+{
+ if (const Q_PID processInfoStruct = p.pid())
+ return processInfoStruct->dwProcessId;
+ return 0;
+}
+#else
+inline Q_PID processId(const QProcess &p)
+{
+ return p.pid();
+}
+#endif
+
+
enum { debug = 0 };
namespace trk {
@@ -47,7 +65,11 @@ struct BluetoothListenerPrivate {
BluetoothListenerPrivate();
QString device;
QProcess process;
+#ifdef Q_OS_WIN
+ DWORD pid;
+#else
Q_PID pid;
+#endif
bool printConsoleMessages;
BluetoothListener::Mode mode;
};
@@ -110,7 +132,7 @@ int BluetoothListener::terminateProcess()
qDebug() << "terminateProcess" << d->process.pid() << d->process.state();
if (d->process.state() == QProcess::NotRunning)
return -1;
- emitMessage(tr("%1: Stopping listener %2...").arg(d->device).arg(d->process.pid()));
+ emitMessage(tr("%1: Stopping listener %2...").arg(d->device).arg(processId(d->process)));
// When listening, the process should terminate by itself after closing the connection
if (mode() == Listen && d->process.waitForFinished(TimeOutMS))
return 0;
@@ -147,8 +169,8 @@ bool BluetoothListener::start(const QString &device, QString *errorMessage)
*errorMessage = tr("Unable to run '%1': %2").arg(binary, d->process.errorString());
return false;
}
- d->pid = d->process.pid(); // Forgets it after crash/termination
- emitMessage(tr("%1: Bluetooth listener running (%2).").arg(device).arg(d->process.pid()));
+ d->pid = processId(d->process); // Forgets it after crash/termination
+ emitMessage(tr("%1: Bluetooth listener running (%2).").arg(device).arg(processId(d->process)));
return true;
}