Prevent use of not existent devices when fiddling with user device parameters. Fixes issue #510 partially

pull/530/head
f4exb 2020-05-20 08:27:39 +02:00
rodzic 3823f2b621
commit 187502b5f3
2 zmienionych plików z 90 dodań i 0 usunięć

Wyświetl plik

@ -1656,6 +1656,21 @@ void MainWindow::sampleSourceChanged()
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()));
if (deviceUI->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainWindow::sampleSourceChanged: non existent device replaced by File Input");
int deviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex);
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceUI->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceUI->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceIndex));
}
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
@ -1751,6 +1766,21 @@ void MainWindow::sampleSinkChanged()
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()));
if (deviceUI->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainWindow::sampleSinkChanged: non existent device replaced by File Sink");
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileSinkDeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceUI->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceUI->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
}
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
@ -1841,6 +1871,21 @@ void MainWindow::sampleMIMOChanged()
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(
DeviceEnumerator::instance()->getMIMOPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()));
if (deviceUI->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainWindow::sampleMIMOChanged: non existent device replaced by Test MIMO");
int testMIMODeviceIndex = DeviceEnumerator::instance()->getTestMIMODeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(testMIMODeviceIndex);
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceUI->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceUI->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(testMIMODeviceIndex));
}
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {

Wyświetl plik

@ -437,6 +437,21 @@ void MainCore::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(selectedDeviceIndex));
if (deviceSet->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainCore::changeSampleSource: non existent device replaced by File Input");
int deviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex);
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceIndex));
}
// add to buddies list
std::vector<DeviceSet*>::iterator it = m_deviceSets.begin();
int nbOfBuddies = 0;
@ -505,6 +520,21 @@ void MainCore::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(selectedDeviceIndex));
if (deviceSet->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainCore::changeSampleSink: non existent device replaced by File Sink");
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileSinkDeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
}
// add to buddies list
std::vector<DeviceSet*>::iterator it = m_deviceSets.begin();
int nbOfBuddies = 0;
@ -572,6 +602,21 @@ void MainCore::changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(selectedDeviceIndex));
if (deviceSet->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainCore::changeSampleMIMO: non existent device replaced by Test MIMO");
int testMIMODeviceIndex = DeviceEnumerator::instance()->getTestMIMODeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(testMIMODeviceIndex);
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(testMIMODeviceIndex));
}
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {