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 { ...@@ -89,9 +89,7 @@ Control {
} }
function accept(index) { function accept(index) {
AvAdapter.stopAudioMeter() AvAdapter.stopAudioMeter()
AVModel.setInputDevice(listModel.data( AVModel.setInputDevice(index)
listModel.index(index, 0),
AudioDeviceModel.RawDeviceName))
AvAdapter.startAudioMeter() AvAdapter.startAudioMeter()
} }
}, },
......
...@@ -782,7 +782,7 @@ AVModelPimpl::getDevice(int type) const ...@@ -782,7 +782,7 @@ AVModelPimpl::getDevice(int type) const
{ {
if (type < 0 || type > 2) if (type < 0 || type > 2)
return {}; // No device return {}; // No device
QString result = ""; QString result;
VectorString devices; VectorString devices;
switch (type) { switch (type) {
case 1: // INPUT case 1: // INPUT
...@@ -797,16 +797,12 @@ AVModelPimpl::getDevice(int type) const ...@@ -797,16 +797,12 @@ AVModelPimpl::getDevice(int type) const
} }
QStringList currentDevicesIdx = ConfigurationManager::instance().getCurrentAudioDevicesIndex(); QStringList currentDevicesIdx = ConfigurationManager::instance().getCurrentAudioDevicesIndex();
try { 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 ""; return "";
}
auto deviceIdx = currentDevicesIdx[type].toInt(); auto deviceIdx = currentDevicesIdx[type].toInt();
if (deviceIdx > devices.size()) { if (deviceIdx < devices.size())
// Should not happen, but cannot retrieve current ringtone device result = devices.at(deviceIdx);
return "";
}
result = devices[deviceIdx];
} catch (std::bad_alloc& ba) { } catch (std::bad_alloc& ba) {
qWarning() << "bad_alloc caught: " << ba.what(); qWarning() << "bad_alloc caught: " << ba.what();
return ""; return "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment