mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Workaround for invalid bluetooth device names
Owing to bug #1002 invalid bluetooth device addresses of the form "devicename (deviceaddress)" or "deviceaddress (devicename)" may have found their way into the preferences. Recognize such names and extract the correct address. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3c022d8673
commit
779292a322
1 changed files with 16 additions and 0 deletions
|
@ -291,6 +291,22 @@ void DCDeviceData::setProduct(const QString& product)
|
|||
|
||||
void DCDeviceData::setDevName(const QString& devName)
|
||||
{
|
||||
// This is a workaround for bug #1002. A string of the form "devicename (deviceaddress)"
|
||||
// or "deviceaddress (devicename)" may have found its way into the preferences.
|
||||
// Try to fetch the address from such a string
|
||||
// TODO: Remove this code in due course
|
||||
if (data.bluetooth_mode) {
|
||||
int idx1 = devName.indexOf('(');
|
||||
int idx2 = devName.lastIndexOf(')');
|
||||
if (idx1 >= 0 && idx2 >= 0 && idx2 > idx1) {
|
||||
QString front = devName.left(idx1).trimmed();
|
||||
QString back = devName.mid(idx1 + 1, idx2 - idx1 - 1);
|
||||
QString newDevName = back.indexOf(':') >= 0 ? back : front;
|
||||
qWarning() << "Found invalid bluetooth device" << devName << "corrected to" << newDevName << ".";
|
||||
data.devname = strdup(qPrintable(newDevName));
|
||||
return;
|
||||
}
|
||||
}
|
||||
data.devname = strdup(qPrintable(devName));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue