]> sigrok.org Git - pulseview.git/commitdiff
Fix #1153 by only showing drivers we'll actually scan
authorSoeren Apel <redacted>
Mon, 9 Apr 2018 16:50:28 +0000 (18:50 +0200)
committerSoeren Apel <redacted>
Sun, 15 Apr 2018 06:19:59 +0000 (08:19 +0200)
pv/devicemanager.cpp
pv/devicemanager.hpp

index 5920486a9d6d8df54f7bb8dc8135bc38ff1620a8..ca8f66bee5316e6116d4fb38afcbdd93ca78a24d 100644 (file)
@@ -87,6 +87,11 @@ DeviceManager::DeviceManager(shared_ptr<Context> context,
        for (auto entry : context->drivers()) {
                if (!do_scan)
                        break;
        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)));
 
                progress->setLabelText(QObject::tr("Scanning for %1...")
                        .arg(QString::fromStdString(entry.first)));
 
@@ -218,14 +223,8 @@ DeviceManager::drive_scan_options(vector<string> user_spec,
        return result;
 }
 
        return result;
 }
 
-list< shared_ptr<devices::HardwareDevice> >
-DeviceManager::driver_scan(
-       shared_ptr<Driver> driver, map<const ConfigKey *, VariantBase> drvopts)
+bool DeviceManager::driver_supported(shared_ptr<Driver> driver) const
 {
 {
-       list< shared_ptr<devices::HardwareDevice> > driver_devices;
-
-       assert(driver);
-
        /*
         * We currently only support devices that can deliver samples at
         * a fixed samplerate (i.e. oscilloscopes and logic analysers).
        /*
         * 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();
         * @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<devices::HardwareDevice> >
+DeviceManager::driver_scan(
+       shared_ptr<Driver> driver, map<const ConfigKey *, VariantBase> drvopts)
+{
+       list< shared_ptr<devices::HardwareDevice> > driver_devices;
+
+       assert(driver);
+
+       if (!driver_supported(driver))
                return driver_devices;
 
        // Remove any device instances from this driver from the device
                return driver_devices;
 
        // Remove any device instances from this driver from the device
index 92ed7dea5f85329567ca525ca2e955285df69212..9b8ef3d120a3a4c68f97a9e359156270516ed4eb 100644 (file)
@@ -70,6 +70,8 @@ public:
        const list< shared_ptr<devices::HardwareDevice> >& devices() const;
        shared_ptr<devices::HardwareDevice> user_spec_device() const;
 
        const list< shared_ptr<devices::HardwareDevice> >& devices() const;
        shared_ptr<devices::HardwareDevice> user_spec_device() const;
 
+       bool driver_supported(shared_ptr<sigrok::Driver> driver) const;
+
        list< shared_ptr<devices::HardwareDevice> > driver_scan(
                shared_ptr<sigrok::Driver> driver,
                map<const sigrok::ConfigKey *, Glib::VariantBase> drvopts);
        list< shared_ptr<devices::HardwareDevice> > driver_scan(
                shared_ptr<sigrok::Driver> driver,
                map<const sigrok::ConfigKey *, Glib::VariantBase> drvopts);