Commit ff3bb8f3a2befbdc8b8f04056b889bb35b46871a
Committed by
David Gräff
1 parent
9d0ebc77
Reset the device pointer before libusb_exit().
unique_ptr deletes target pointer when variable scope ends. For variable "device" this is the whole main() function. So Device is destroyed after main() is finished. Device descructor is calling libusb_close. According to documentation no libusb function is allowed to be called after libusb_exit(). Fixes #195
Showing
1 changed file
with
4 additions
and
1 deletions
openhantek/src/main.cpp
| ... | ... | @@ -205,7 +205,10 @@ int main(int argc, char *argv[]) { |
| 205 | 205 | postProcessingThread.quit(); |
| 206 | 206 | postProcessingThread.wait(10000); |
| 207 | 207 | |
| 208 | - if (context && device != nullptr) { libusb_exit(context); } | |
| 208 | + if (context && device != nullptr) { | |
| 209 | + device.reset(); // causes libusb_close(), which must be called before libusb_exit() | |
| 210 | + libusb_exit(context); | |
| 211 | + } | |
| 209 | 212 | |
| 210 | 213 | return res; |
| 211 | 214 | } | ... | ... |