From b58bb644e87129d292582820ce5c02aee3c39f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Wed, 24 Aug 2022 20:58:49 -0400 Subject: [PATCH] avmodel: check index Change-Id: Ic51fda2e43e27fad851ab33d6e091124c645011b --- src/app/mainview/components/CallActionBar.qml | 4 +--- src/libclient/avmodel.cpp | 14 +++++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/app/mainview/components/CallActionBar.qml b/src/app/mainview/components/CallActionBar.qml index 15c0b9b1e..159ca617b 100644 --- a/src/app/mainview/components/CallActionBar.qml +++ b/src/app/mainview/components/CallActionBar.qml @@ -89,9 +89,7 @@ Control { } function accept(index) { AvAdapter.stopAudioMeter() - AVModel.setInputDevice(listModel.data( - listModel.index(index, 0), - AudioDeviceModel.RawDeviceName)) + AVModel.setInputDevice(index) AvAdapter.startAudioMeter() } }, diff --git a/src/libclient/avmodel.cpp b/src/libclient/avmodel.cpp index 932e3fbee..02b8e3f13 100644 --- a/src/libclient/avmodel.cpp +++ b/src/libclient/avmodel.cpp @@ -782,7 +782,7 @@ AVModelPimpl::getDevice(int type) const { if (type < 0 || type > 2) return {}; // No device - QString result = ""; + QString result; VectorString devices; switch (type) { case 1: // INPUT @@ -797,16 +797,12 @@ AVModelPimpl::getDevice(int type) const } QStringList currentDevicesIdx = ConfigurationManager::instance().getCurrentAudioDevicesIndex(); try { - if (currentDevicesIdx.size() < 3) { - // Should not happen, but cannot retrieve current ringtone device + // Should not happen, but cannot retrieve current ringtone device + if (currentDevicesIdx.size() < 3) return ""; - } auto deviceIdx = currentDevicesIdx[type].toInt(); - if (deviceIdx > devices.size()) { - // Should not happen, but cannot retrieve current ringtone device - return ""; - } - result = devices[deviceIdx]; + if (deviceIdx < devices.size()) + result = devices.at(deviceIdx); } catch (std::bad_alloc& ba) { qWarning() << "bad_alloc caught: " << ba.what(); return ""; -- GitLab