summaryrefslogtreecommitdiffstats
path: root/src/bluetooth
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2013-08-23 11:44:16 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-23 15:41:14 +0200
commit944d75d9230205e84d7f0d32adc47aedb1b53d38 (patch)
treec1120e5d632b9f21c8402b9a7339cf981c4c22db /src/bluetooth
parent66aec88aeedc59149945d497fc883586adb5d092 (diff)
QNX: Fix segfault when deleting qrfcommserver
Change-Id: Iefb851c818303c5f8fe2ef783ccfee5d13bcf827 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/bluetooth')
-rw-r--r--src/bluetooth/qrfcommserver.cpp5
-rw-r--r--src/bluetooth/qrfcommserver_qnx.cpp11
2 files changed, 12 insertions, 4 deletions
diff --git a/src/bluetooth/qrfcommserver.cpp b/src/bluetooth/qrfcommserver.cpp
index 7e42186c..b6bbfe77 100644
--- a/src/bluetooth/qrfcommserver.cpp
+++ b/src/bluetooth/qrfcommserver.cpp
@@ -200,6 +200,11 @@ bool QRfcommServer::isListening() const
{
Q_D(const QRfcommServer);
+#ifdef QTM_QNX_BLUETOOTH
+ if (!d->socket)
+ return false;
+#endif
+
return d->socket->state() == QBluetoothSocket::ListeningState;
}
diff --git a/src/bluetooth/qrfcommserver_qnx.cpp b/src/bluetooth/qrfcommserver_qnx.cpp
index dc52c30f..3196341d 100644
--- a/src/bluetooth/qrfcommserver_qnx.cpp
+++ b/src/bluetooth/qrfcommserver_qnx.cpp
@@ -56,15 +56,12 @@ extern QHash<QRfcommServerPrivate*, int> __fakeServerPorts;
QRfcommServerPrivate::QRfcommServerPrivate()
: socket(0),maxPendingConnections(1),securityFlags(QBluetooth::NoSecurity)
{
- socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
ppsRegisterControl();
}
QRfcommServerPrivate::~QRfcommServerPrivate()
{
Q_Q(QRfcommServer);
- if (socket)
- delete socket;
q->close();
__fakeServerPorts.remove(this);
ppsUnregisterControl(this);
@@ -84,6 +81,9 @@ void QRfcommServerPrivate::controlReply(ppsResult result)
if (socketFD == -1) {
qWarning() << Q_FUNC_INFO << "RFCOMM Server: Could not open socket FD" << errno;
} else {
+ if (!socket)
+ return;
+
socket->setSocketDescriptor(socketFD, QBluetoothSocket::RfcommSocket,
QBluetoothSocket::ConnectedState);
socket->connectToService(QBluetoothAddress(nextClientAddress), m_uuid);
@@ -127,6 +127,7 @@ void QRfcommServer::close()
return;
}
d->socket->close();
+ delete d->socket;
d->socket = 0;
ppsSendControlMessage("deregister_server", 0x1101, d->m_uuid, QString(), QString(), 0);
// force active object (socket) to run and shutdown socket.
@@ -138,9 +139,11 @@ bool QRfcommServer::listen(const QBluetoothAddress &address, quint16 port)
Q_UNUSED(address)
Q_D(QRfcommServer);
// listen has already been called before
- if (d->socket->state() == QBluetoothSocket::ListeningState)
+ if (d->socket && d->socket->state() == QBluetoothSocket::ListeningState)
return true;
+ d->socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
+
//We can not register an actual Rfcomm port, because the platform does not allow it
//but we need a way to associate a server with a service