Desktop: Fix use of bluetooth address for remembered dive computer.

Fix a bug causing the bluetooth address not being used when downloading
from a 'remembered' dive computer if the device selection is populated.
This specifically excludes MacOS, as 'remembering' bluetooth connections
does not seem to be working there as per
https://github.com/subsurface/subsurface/pull/2158#issuecomment-508933672.
I am not super sure why we are _not_ trying to use the 'remembered'
device if the device selection is populated (`ui.device->currentIndex()
== -1`) - maybe this should be clarified in a comment?

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2023-02-28 13:55:36 +13:00 committed by Dirk Hohndel
parent 31cf991afe
commit 9da7ec4828
2 changed files with 7 additions and 3 deletions

View file

@ -1,5 +1,6 @@
desktop: add column for dive notes to the dive list table
desktop: fix bug when printing a dive plan with multiple segments
desktop: fix remembering of bluetooth address for remembered dive computers (not MacOS)
desktop: fix bug in bailout gas selection for CCR dives
desktop: fix crash on cylinder update of multiple dives
desktop: use dynamic tank use drop down in equipment tab and planner

View file

@ -147,10 +147,13 @@ void DownloadFromDCWidget::DC##num##Clicked() \
ui.vendor->setCurrentIndex(ui.vendor->findText(qPrefDiveComputer::vendor##num())); \
productModel.setStringList(productList[qPrefDiveComputer::vendor##num()]); \
ui.product->setCurrentIndex(ui.product->findText(qPrefDiveComputer::product##num())); \
ui.bluetoothMode->setChecked(isBluetoothAddress(qPrefDiveComputer::device##num())); \
if (ui.device->currentIndex() == -1) \
bool isBluetoothDevice = isBluetoothAddress(qPrefDiveComputer::device##num()); \
bool isMacOs = QSysInfo::kernelType() == "darwin"; \
ui.bluetoothMode->setChecked(isBluetoothDevice); \
if (ui.device->currentIndex() == -1 || (isBluetoothDevice && !isMacOs)) \
/* macOS seems to have a problem connecting to remembered bluetooth devices if it hasn't already had a connection in the current session */ \
ui.device->setCurrentIndex(deviceIndex(qPrefDiveComputer::device##num())); \
if (QSysInfo::kernelType() == "darwin") { \
if (isMacOs) { \
/* it makes no sense that this would be needed on macOS but not Linux */ \
QCoreApplication::processEvents(); \
ui.vendor->update(); \