From: Soeren Apel Date: Mon, 9 Apr 2018 16:50:28 +0000 (+0200) Subject: Fix #1153 by only showing drivers we'll actually scan X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8d054b91e39afd8e3b04cdde8e37f2c94aa2e608;p=pulseview.git Fix #1153 by only showing drivers we'll actually scan --- 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);