summaryrefslogtreecommitdiffstats
path: root/src/imports/bluetooth
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2014-11-20 15:28:40 +0100
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2014-11-21 12:46:08 +0100
commit839b05ba89134ccc4c4cc7716d18995a4c31b534 (patch)
tree90e3c7383c9097dd6e18065c68d687f02630dacd /src/imports/bluetooth
parent25c2d4793bd4a55eec6e51ccbdfece9e505b8715 (diff)
Add missing InvalidBluetoothAdapterError to QML discovery model
QBluetoothServiceDiscoveryAgent::InvalidBluetoothAdapter was introduced by Qt 5.3 but never added to the QML BluetoothDiscoveryModel. This patch fixes the problem. This was noticed due to a crash on Android emulator. Change-Id: I652576929659ca370216133154e36158e8425711 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/imports/bluetooth')
-rw-r--r--src/imports/bluetooth/plugins.qmltypes3
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp27
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h3
3 files changed, 30 insertions, 3 deletions
diff --git a/src/imports/bluetooth/plugins.qmltypes b/src/imports/bluetooth/plugins.qmltypes
index f7d0d08d..cf2146e2 100644
--- a/src/imports/bluetooth/plugins.qmltypes
+++ b/src/imports/bluetooth/plugins.qmltypes
@@ -30,7 +30,8 @@ Module {
"NoError": 0,
"InputOutputError": 1,
"PoweredOffError": 2,
- "UnknownError": 3
+ "UnknownError": 3,
+ "InvalidBluetoothAdapterError": 4
}
}
Property { name: "error"; type: "Error"; isReadonly: true }
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
index 20f47f65..01a53bfa 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
@@ -151,7 +151,19 @@ void QDeclarativeBluetoothDiscoveryModel::componentComplete()
void QDeclarativeBluetoothDiscoveryModel::errorDiscovery(QBluetoothServiceDiscoveryAgent::Error error)
{
- d->m_error = static_cast<QDeclarativeBluetoothDiscoveryModel::Error>(error);
+ switch (error) {
+ case QBluetoothServiceDiscoveryAgent::InvalidBluetoothAdapterError:
+ d->m_error = QDeclarativeBluetoothDiscoveryModel::InvalidBluetoothAdapterError; break;
+ case QBluetoothServiceDiscoveryAgent::NoError:
+ d->m_error = QDeclarativeBluetoothDiscoveryModel::NoError; break;
+ case QBluetoothServiceDiscoveryAgent::InputOutputError:
+ d->m_error = QDeclarativeBluetoothDiscoveryModel::InputOutputError; break;
+ case QBluetoothServiceDiscoveryAgent::PoweredOffError:
+ d->m_error = QDeclarativeBluetoothDiscoveryModel::PoweredOffError; break;
+ case QBluetoothServiceDiscoveryAgent::UnknownError:
+ d->m_error = QDeclarativeBluetoothDiscoveryModel::UnknownError; break;
+ }
+
emit errorChanged();
}
@@ -187,6 +199,12 @@ void QDeclarativeBluetoothDiscoveryModel::clearModel()
\li An IO failure occurred during device discovery
\row \li \c BluetoothDiscoveryModel.PoweredOffError
\li The bluetooth device is not powered on.
+ \row \li \c BluetoothDiscoveryModel.InvalidBluetoothAdapterError
+ \li There is no default Bluetooth device to perform the
+ service discovery. The model always uses the local default adapter.
+ Specifying a default adapter is not possible. If that's required,
+ \l QBluetoothServiceDiscoveryAgent should be directly used. This
+ value was introduced by Qt 5.4.
\row \li \c BluetoothDiscoveryModel.UnknownError
\li An unknown error occurred.
\endtable
@@ -407,6 +425,13 @@ void QDeclarativeBluetoothDiscoveryModel::setRunning(bool running)
//qDebug() << "Minimal Discovery";
d->m_serviceAgent->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
}
+
+ // we could not start service discovery
+ if (!d->m_serviceAgent->isActive()) {
+ d->m_running = false;
+ errorDiscovery(d->m_serviceAgent->error());
+ return;
+ }
}
}
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
index 279fb063..1834ce36 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
@@ -94,7 +94,8 @@ public:
NoError,
InputOutputError,
PoweredOffError,
- UnknownError
+ UnknownError,
+ InvalidBluetoothAdapterError
};
Error error() const;