* @brief Closes the device, tears down all active transfers, and stops the read thread. The * QThread::started connections are detached here so the next open() cycle re-wires exactly one * read slot instead of double-connecting. */
| 242 | * read slot instead of double-connecting. |
| 243 | */ |
| 244 | void IO::Drivers::USB::close() |
| 245 | { |
| 246 | Q_ASSERT(m_ctx != nullptr); |
| 247 | Q_ASSERT(m_activeInEp != 0 || m_handle == nullptr); |
| 248 | |
| 249 | stopReadThread(); |
| 250 | cancelAndDrainTransfers(); |
| 251 | freeTransfers(); |
| 252 | |
| 253 | disconnect(&m_readThread, &QThread::started, this, &USB::readLoop); |
| 254 | disconnect(&m_readThread, &QThread::started, this, &USB::isoReadLoop); |
| 255 | |
| 256 | if (m_handle) { |
| 257 | releaseInterface(); |
| 258 | libusb_close(m_handle); |
| 259 | m_handle = nullptr; |
| 260 | } |
| 261 | |
| 262 | m_activeInEp = 0; |
| 263 | m_activeOutEp = 0; |
| 264 | |
| 265 | Q_EMIT configurationChanged(); |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * @brief Returns true when a USB device handle is open. |
no outgoing calls
no test coverage detected