bluetooth: there may be no active local device
Which would lead to NULL dereference. Related: update friendly name field on device change. Fixes: #20137 Change-Id: I909501017f92952d97791ff88202ace12ac5623a Reviewed-on: https://review.haiku-os.org/c/haiku/+/11167 Haiku-Format: Haiku-format Bot <[email protected]> Reviewed-by: Máximo Castañeda <[email protected]> Reviewed-by: Mohammed R. Attia <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -83,7 +83,12 @@ BluetoothSettingsView::BluetoothSettingsView(const char* name)
|
|||||||
B_TRANSLATE("Local devices found on system:"),
|
B_TRANSLATE("Local devices found on system:"),
|
||||||
fLocalDevicesMenu);
|
fLocalDevicesMenu);
|
||||||
|
|
||||||
|
fFriendlyName = new BTextControl("FriendlyName", B_TRANSLATE("Friendly Name:"), NULL,
|
||||||
|
new BMessage(kMsgSetFriendlyName));
|
||||||
|
|
||||||
if (ActiveLocalDevice != NULL) {
|
if (ActiveLocalDevice != NULL) {
|
||||||
|
fFriendlyName->SetText(ActiveLocalDevice->GetFriendlyName());
|
||||||
|
|
||||||
fExtDeviceView->SetLocalDevice(ActiveLocalDevice);
|
fExtDeviceView->SetLocalDevice(ActiveLocalDevice);
|
||||||
fExtDeviceView->SetEnabled(true);
|
fExtDeviceView->SetEnabled(true);
|
||||||
|
|
||||||
@@ -102,9 +107,6 @@ BluetoothSettingsView::BluetoothSettingsView(const char* name)
|
|||||||
|
|
||||||
fClassMenu->SetValue(_GetClassForMenu());
|
fClassMenu->SetValue(_GetClassForMenu());
|
||||||
|
|
||||||
fFriendlyName = new BTextControl("FriendlyName", B_TRANSLATE("Friendly Name:"),
|
|
||||||
ActiveLocalDevice->GetFriendlyName(), new BMessage(kMsgSetFriendlyName));
|
|
||||||
|
|
||||||
BLayoutBuilder::Grid<>(this, 0)
|
BLayoutBuilder::Grid<>(this, 0)
|
||||||
.SetInsets(10)
|
.SetInsets(10)
|
||||||
|
|
||||||
@@ -195,6 +197,9 @@ BluetoothSettingsView::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case kMsgSetFriendlyName:
|
case kMsgSetFriendlyName:
|
||||||
{
|
{
|
||||||
|
if (ActiveLocalDevice == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
BString friendlyName = fFriendlyName->Text();
|
BString friendlyName = fFriendlyName->Text();
|
||||||
|
|
||||||
BMenuItem* item = fLocalDevicesMenu->FindItem(ActiveLocalDevice->GetFriendlyName());
|
BMenuItem* item = fLocalDevicesMenu->FindItem(ActiveLocalDevice->GetFriendlyName());
|
||||||
@@ -286,6 +291,7 @@ BluetoothSettingsView::_MarkLocalDevice(LocalDevice* lDevice)
|
|||||||
if (bdaddrUtils::Compare(lDevice->GetBluetoothAddress(), BDADDR_NULL))
|
if (bdaddrUtils::Compare(lDevice->GetBluetoothAddress(), BDADDR_NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
fFriendlyName->SetText(lDevice->GetFriendlyName());
|
||||||
fExtDeviceView->SetLocalDevice(lDevice);
|
fExtDeviceView->SetLocalDevice(lDevice);
|
||||||
fExtDeviceView->SetEnabled(true);
|
fExtDeviceView->SetEnabled(true);
|
||||||
ActiveLocalDevice = lDevice;
|
ActiveLocalDevice = lDevice;
|
||||||
|
|||||||
Reference in New Issue
Block a user