attempt to connect at startup with empty devicelist (triggers udev info msg)

This commit is contained in:
Jan Käberich 2022-01-05 12:13:57 +01:00
parent 1194894a12
commit dd8f0c4fa9
2 changed files with 7 additions and 4 deletions

View File

@ -171,7 +171,10 @@ Device::Device(QString serial)
if(!m_handle) {
QString message = "No device found";
if(!serial.isEmpty()) {
// only show error message if specific device was requested
InformationBox::ShowError("Error opening device", message);
}
libusb_exit(m_context);
throw std::runtime_error(message.toStdString());
return;
@ -356,8 +359,7 @@ void Device::SearchDevices(std::function<bool (libusb_device_handle *, QString)>
message.append(libusb_strerror((libusb_error) ret));
message.append("\" On Linux this is most likely caused by a missing udev rule. "
"On Windows this most likely means that you are already connected to "
"this device (is another instance of the application already runnning? "
"If that is not the case, you can try installing the WinUSB driver using Zadig (https://zadig.akeo.ie/)");
"this device (is another instance of the application already runnning?)");
qWarning() << message;
InformationBox::ShowError("Error opening device", message);
}

View File

@ -242,7 +242,8 @@ AppWindow::AppWindow(QWidget *parent)
qRegisterMetaType<Protocol::AmplitudeCorrectionPoint>("AmplitudeCorrection");
// List available devices
if(UpdateDeviceList() && Preferences::getInstance().Startup.ConnectToFirstDevice) {
UpdateDeviceList();
if(Preferences::getInstance().Startup.ConnectToFirstDevice) {
// at least one device available
ConnectToDevice();
}