Verify USB listener callback handle

Do not use `handle` if `libusb_hotplug_register_callback` fails
This commit is contained in:
Rafael Sadowski 2024-06-08 07:02:38 +02:00 committed by Jonathan White
parent 29feb5da79
commit 59bd71ddca
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01

View File

@ -97,11 +97,13 @@ DeviceListenerLibUsb::registerHotplugCallback(bool arrived, bool left, int vendo
// Avoid race conditions
m_usbEvents.waitForFinished();
}
if (!m_usbEvents.isRunning()) {
m_completed = false;
m_usbEvents = QtConcurrent::run(handleUsbEvents, static_cast<libusb_context*>(m_ctx), &m_completed);
if (handle > 0) {
m_callbackHandles.insert(handle);
if (!m_usbEvents.isRunning()) {
m_completed = false;
m_usbEvents = QtConcurrent::run(handleUsbEvents, static_cast<libusb_context*>(m_ctx), &m_completed);
}
}
m_callbackHandles.insert(handle);
return handle;
}