From 658089d763c1e9e953f5c06b01d028613408138b Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 14 May 2020 12:15:24 -0700 Subject: core/bt: match DC descriptor in lower case This fixes a rather subtle bug. In btdiscovery.cpp we are detecting dive computers based on their BT name and are setting up product+vendor as the key for that lookup. QMap always uses case sensitive comparisons and a tiny inconsistency snuck into our code. libdivecomputer names for the Aqualung dive computers i200C / i300C / i550C end in an upper case C (as matches the official branding), but in btdiscovery.cpp we have those names with lower case c. And therefore didn't recognize these dive computers. Obviously this is easy to fix by fixing those three strings, but I decided that it was silly to set ourselves up for similar oversights in the future. So instead I switched the matching of the descriptor to simply be allways all lower case. Signed-off-by: Dirk Hohndel --- desktop-widgets/configuredivecomputerdialog.cpp | 2 +- desktop-widgets/downloadfromdivecomputer.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/configuredivecomputerdialog.cpp b/desktop-widgets/configuredivecomputerdialog.cpp index 2315f47ea..6fd855648 100644 --- a/desktop-widgets/configuredivecomputerdialog.cpp +++ b/desktop-widgets/configuredivecomputerdialog.cpp @@ -908,7 +908,7 @@ void ConfigureDiveComputerDialog::getDeviceData() device_data.vendor = copy_qstring(selected_vendor); device_data.product = copy_qstring(selected_product); - device_data.descriptor = descriptorLookup.value(selected_vendor + selected_product); + device_data.descriptor = descriptorLookup.value(selected_vendor.toLower() + selected_product.toLower()); device_data.deviceid = device_data.diveid = 0; qPrefDiveComputer::set_device(device_data.devname); diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index cf3aad492..3c84683af 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -318,7 +318,7 @@ void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString &vendor) productModel.setStringList(productList[vendor]); ui.product->setCurrentIndex(0); - descriptor = descriptorLookup.value(ui.vendor->currentText() + ui.product->currentText()); + descriptor = descriptorLookup.value(ui.vendor->currentText().toLower() + ui.product->currentText().toLower()); transport = dc_descriptor_get_transports(descriptor); fill_device_list(transport); } @@ -542,7 +542,7 @@ void DownloadFromDCWidget::updateDeviceEnabled() { // Set up the DC descriptor dc_descriptor_t *descriptor = NULL; - descriptor = descriptorLookup.value(ui.vendor->currentText() + ui.product->currentText()); + descriptor = descriptorLookup.value(ui.vendor->currentText().toLower() + ui.product->currentText().toLower()); // call dc_descriptor_get_transport to see if the dc_transport_t is DC_TRANSPORT_SERIAL if (dc_descriptor_get_transports(descriptor) & (DC_TRANSPORT_SERIAL | DC_TRANSPORT_USBSTORAGE)) { -- cgit v1.2.3-70-g09d2