summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth/qbluetoothsocket.cpp')
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp
index 36e4a54c..62633bb1 100644
--- a/src/bluetooth/qbluetoothsocket.cpp
+++ b/src/bluetooth/qbluetoothsocket.cpp
@@ -518,10 +518,20 @@ QBluetooth::SecurityFlags QBluetoothSocket::preferredSecurityFlags() const
void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
{
Q_D(QBluetoothSocketBase);
- SocketState old = d->state;
+ const SocketState old = d->state;
+ if (state == old)
+ return;
+
d->state = state;
if(old != d->state)
emit stateChanged(state);
+ if (state == QBluetoothSocket::ConnectedState) {
+ emit connected();
+ } else if ((old == QBluetoothSocket::ConnectedState
+ || old == QBluetoothSocket::ClosingState)
+ && state == QBluetoothSocket::UnconnectedState) {
+ emit disconnected();
+ }
if(state == ListeningState){
// TODO: look at this, is this really correct?
// if we're a listening socket we can't handle connects?