From 1d6e35dcef7686faec065cb775bd211fa47f2b73 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Wed, 24 Jan 2018 21:11:50 +0100 Subject: [PATCH] main: introduce -D cmdline option, don't auto-scan for devices Add a -D command line option which skips auto-detection of devices upon startup. This can speedup program startup for setups with known devices, and allows to skip the scan for troubled drivers which might break the startup phase. This -D option can be combined with -d specs, either presence or absence of -d is acceptable when -D is specified. Users still can interactively scan for and use devices after program startup. This resolves bug #1116. --- main.cpp | 10 ++++++++-- pv/devicemanager.cpp | 5 ++++- pv/devicemanager.hpp | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 0f9aec2f..cd7e65d3 100644 --- a/main.cpp +++ b/main.cpp @@ -68,6 +68,7 @@ void usage() " -V, --version Show release version\n" " -l, --loglevel Set libsigrok/libsigrokdecode loglevel\n" " -d, --driver Specify the device driver to use\n" + " -D, --no-scan Don't auto-scan for devices, use -d spec only\n" " -i, --input-file Load input from file\n" " -I, --input-format Input format\n" " -c, --clean Don't restore previous sessions on startup\n" @@ -80,6 +81,7 @@ int main(int argc, char *argv[]) shared_ptr context; string open_file, open_file_format, driver; bool restore_sessions = true; + bool do_scan = true; Application a(argc, argv); @@ -103,7 +105,7 @@ int main(int argc, char *argv[]) }; const int c = getopt_long(argc, argv, - "l:Vhc?d:i:I:", long_options, nullptr); + "l:Vhc?d:Di:I:", long_options, nullptr); if (c == -1) break; @@ -143,6 +145,10 @@ int main(int argc, char *argv[]) driver = optarg; break; + case 'D': + do_scan = false; + break; + case 'i': open_file = optarg; break; @@ -187,7 +193,7 @@ int main(int argc, char *argv[]) try { // Create the device manager, initialise the drivers - pv::DeviceManager device_manager(context, driver); + pv::DeviceManager device_manager(context, driver, do_scan); // Initialise the main window pv::MainWindow w(device_manager); diff --git a/pv/devicemanager.cpp b/pv/devicemanager.cpp index ccd3716a..5920486a 100644 --- a/pv/devicemanager.cpp +++ b/pv/devicemanager.cpp @@ -56,7 +56,8 @@ using sigrok::Driver; namespace pv { -DeviceManager::DeviceManager(shared_ptr context, std::string driver) : +DeviceManager::DeviceManager(shared_ptr context, + std::string driver, bool do_scan) : context_(context) { unique_ptr progress(new QProgressDialog("", @@ -84,6 +85,8 @@ DeviceManager::DeviceManager(shared_ptr context, std::string driver) : * best effort auto detection. */ for (auto entry : context->drivers()) { + if (!do_scan) + break; progress->setLabelText(QObject::tr("Scanning for %1...") .arg(QString::fromStdString(entry.first))); diff --git a/pv/devicemanager.hpp b/pv/devicemanager.hpp index 2c934300..92ed7dea 100644 --- a/pv/devicemanager.hpp +++ b/pv/devicemanager.hpp @@ -58,7 +58,8 @@ class Session; class DeviceManager { public: - DeviceManager(shared_ptr context, std::string driver); + DeviceManager(shared_ptr context, + std::string driver, bool do_scan); ~DeviceManager() = default; -- 2.30.2