summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--examples/bluetooth/scanner/scanner.qml2
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.cpp3
-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
5 files changed, 34 insertions, 4 deletions
diff --git a/examples/bluetooth/scanner/scanner.qml b/examples/bluetooth/scanner/scanner.qml
index 67aaecf0..543e19de 100644
--- a/examples/bluetooth/scanner/scanner.qml
+++ b/examples/bluetooth/scanner/scanner.qml
@@ -60,6 +60,8 @@ Item {
console.log("Error: Bluetooth device not turned on"); break;
case BluetoothDiscoveryModel.InputOutputError:
console.log("Error: Bluetooth I/O Error"); break;
+ case BluetoothDiscoveryModel.InvalidBluetoothAdapterError:
+ console.log("Error: Invalid Bluetooth Adapter Error"); break;
case BluetoothDiscoveryModel.NoError:
break;
default:
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
index c800dc6d..ef28ef82 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
@@ -91,7 +91,8 @@ QT_BEGIN_NAMESPACE
\value PoweredOffError The Bluetooth adaptor is powered off, power it on before doing discovery.
\value InputOutputError Writing or reading from the device resulted in an error.
\value InvalidBluetoothAdapterError The passed local adapter address does not match the physical
- adapter address of any local Bluetooth device.
+ adapter address of any local Bluetooth device. This value
+ was introduced by Qt 5.3.
\value UnknownError An unknown error has occurred.
*/
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;