Skip to content
Snippets Groups Projects
Commit b58bb644 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

avmodel: check index

Change-Id: Ic51fda2e43e27fad851ab33d6e091124c645011b
parent 5995d9b5
No related branches found
No related tags found
No related merge requests found
......@@ -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()
}
},
......
......@@ -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 "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment