From 8d054b91e39afd8e3b04cdde8e37f2c94aa2e608 Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Mon, 9 Apr 2018 18:50:28 +0200 Subject: [PATCH 1/1] Fix #1153 by only showing drivers we'll actually scan --- pv/devicemanager.cpp | 29 +++++++++++++++++++---------- pv/devicemanager.hpp | 2 ++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/pv/devicemanager.cpp b/pv/devicemanager.cpp index 5920486a..ca8f66be 100644 --- a/pv/devicemanager.cpp +++ b/pv/devicemanager.cpp @@ -87,6 +87,11 @@ DeviceManager::DeviceManager(shared_ptr context, for (auto entry : context->drivers()) { if (!do_scan) break; + + // Skip drivers we won't scan anyway + if (!driver_supported(entry.second)) + continue; + progress->setLabelText(QObject::tr("Scanning for %1...") .arg(QString::fromStdString(entry.first))); @@ -218,14 +223,8 @@ DeviceManager::drive_scan_options(vector user_spec, return result; } -list< shared_ptr > -DeviceManager::driver_scan( - shared_ptr driver, map drvopts) +bool DeviceManager::driver_supported(shared_ptr driver) const { - list< shared_ptr > driver_devices; - - assert(driver); - /* * We currently only support devices that can deliver samples at * a fixed samplerate (i.e. oscilloscopes and logic analysers). @@ -233,9 +232,19 @@ DeviceManager::driver_scan( * @todo Add support for non-monotonic devices (DMMs, sensors, etc). */ const auto keys = driver->config_keys(); - bool supported_device = keys.count(ConfigKey::LOGIC_ANALYZER) | - keys.count(ConfigKey::OSCILLOSCOPE); - if (!supported_device) + + return keys.count(ConfigKey::LOGIC_ANALYZER) | keys.count(ConfigKey::OSCILLOSCOPE); +} + +list< shared_ptr > +DeviceManager::driver_scan( + shared_ptr driver, map drvopts) +{ + list< shared_ptr > driver_devices; + + assert(driver); + + if (!driver_supported(driver)) return driver_devices; // Remove any device instances from this driver from the device diff --git a/pv/devicemanager.hpp b/pv/devicemanager.hpp index 92ed7dea..9b8ef3d1 100644 --- a/pv/devicemanager.hpp +++ b/pv/devicemanager.hpp @@ -70,6 +70,8 @@ public: const list< shared_ptr >& devices() const; shared_ptr user_spec_device() const; + bool driver_supported(shared_ptr driver) const; + list< shared_ptr > driver_scan( shared_ptr driver, map drvopts); -- 2.30.2