fix crash in BT setup
This commit is contained in:
parent
e5746f50cb
commit
bf7590c343
@ -157,22 +157,22 @@ void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo
|
|||||||
|
|
||||||
// Check if we already have added this device info
|
// Check if we already have added this device info
|
||||||
foreach (BluetoothDeviceInfo *di, m_deviceInfos->deviceInfos()) {
|
foreach (BluetoothDeviceInfo *di, m_deviceInfos->deviceInfos()) {
|
||||||
if (di->name() == deviceInformation->name() && di->address() == deviceInformation->address()) {
|
if (di->address() == deviceInformation->address()) {
|
||||||
qWarning() << "BluetoothDiscover: device" << deviceInformation->name() << "(" << deviceInformation->address() << ") already added";
|
qWarning() << "BluetoothDiscover: device" << deviceInformation->name() << "(" << deviceInformation->address() << ") already added";
|
||||||
deviceInformation->deleteLater();
|
deviceInformation->deleteLater();
|
||||||
deviceInformation = nullptr;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceInformation)
|
m_deviceInfos->addBluetoothDeviceInfo(deviceInformation);
|
||||||
m_deviceInfos->addBluetoothDeviceInfo(deviceInformation);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BluetoothDiscovery::discoveryFinished()
|
void BluetoothDiscovery::discoveryFinished()
|
||||||
{
|
{
|
||||||
qDebug() << "BluetoothDiscovery: Discovery finished";
|
qDebug() << "BluetoothDiscovery: Discovery finished";
|
||||||
setDiscovering(false);
|
if (m_enabled) {
|
||||||
|
m_discoveryAgent->start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BluetoothDiscovery::onError(const QBluetoothDeviceDiscoveryAgent::Error &error)
|
void BluetoothDiscovery::onError(const QBluetoothDeviceDiscoveryAgent::Error &error)
|
||||||
|
|||||||
@ -10,19 +10,8 @@ Page {
|
|||||||
header: GuhHeader {
|
header: GuhHeader {
|
||||||
text: qsTr("Bluetooth discovery")
|
text: qsTr("Bluetooth discovery")
|
||||||
onBackPressed: pageStack.pop()
|
onBackPressed: pageStack.pop()
|
||||||
|
|
||||||
HeaderButton {
|
|
||||||
imageSource: Qt.resolvedUrl("../images/refresh.svg")
|
|
||||||
onClicked: {
|
|
||||||
if (Engine.bluetoothDiscovery.bluetoothAvailable) {
|
|
||||||
Engine.bluetoothDiscovery.start()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enabled: Engine.bluetoothDiscovery.bluetoothAvailable && Engine.bluetoothDiscovery.bluetoothEnabled && !Engine.bluetoothDiscovery.discovering
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Component.onCompleted: Engine.bluetoothDiscovery.start()
|
Component.onCompleted: Engine.bluetoothDiscovery.start()
|
||||||
|
|
||||||
function setupDevice(name, btAddress) {
|
function setupDevice(name, btAddress) {
|
||||||
@ -30,6 +19,15 @@ Page {
|
|||||||
pageStack.push(connectingPageComponent, { name: name, address: btAddress } )
|
pageStack.push(connectingPageComponent, { name: name, address: btAddress } )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: pageStack
|
||||||
|
onCurrentItemChanged: {
|
||||||
|
if (pageStack.currentItem === root) {
|
||||||
|
Engine.bluetoothDiscovery.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: app.margins
|
spacing: app.margins
|
||||||
|
|||||||
Reference in New Issue
Block a user