Input preferences: fix list item retrieval

Fixes #16679

Change-Id: I87844b7745dc2d9e126983a888caf01f37f6b742
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3540
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Máximo Castañeda 2020-12-20 21:54:13 +01:00 committed by Adrien Destugues
parent 6011ce6c74
commit a0f0cb5a9d

View File

@ -113,11 +113,11 @@ InputWindow::MessageReceived(BMessage* message)
if (device) if (device)
AddDevice(device); AddDevice(device);
} else { } else {
for (int i = 0; i < fDeviceListView->CountItems(); for (int i = 0; i < fDeviceListView->CountItems(); i++) {
i++) { DeviceListItemView* item =
BStringItem* item = dynamic_cast<BStringItem*>( dynamic_cast<DeviceListItemView*>(
fDeviceListView->ItemAt(i)); fDeviceListView->ItemAt(i));
if (item->Text() == name) { if (item != NULL && item->Label() == name) {
fDeviceListView->RemoveItem(i); fDeviceListView->RemoveItem(i);
BView* settings = fCardView->ChildAt(i); BView* settings = fCardView->ChildAt(i);
fCardView->RemoveChild(settings); fCardView->RemoveChild(settings);