Commit 84f258e2978418c4de35ff41461afa74fe34998a

Authored by viktorxda
Committed by David Gräff
1 parent 6fb6fbe5

fix for libusb dereference crash / update appveyor links (#267)

* update appveyor link in readme.md

* fix for libusb dereference crash (windows)
openhantek/src/usb/usbdevice.cpp
@@ -99,7 +99,13 @@ bool USBDevice::connectDevice(QString &errorMessage) { @@ -99,7 +99,13 @@ bool USBDevice::connectDevice(QString &errorMessage) {
99 return true; 99 return true;
100 } 100 }
101 101
102 -USBDevice::~USBDevice() { disconnectFromDevice(); } 102 +USBDevice::~USBDevice() {
  103 + disconnectFromDevice();
  104 +#if defined(_WIN32) || defined(_WIN64)
  105 + if (device != nullptr) libusb_unref_device(device);
  106 + device = nullptr;
  107 +#endif
  108 +}
103 109
104 int USBDevice::claimInterface(const libusb_interface_descriptor *interfaceDescriptor, int endpointOut, int endPointIn) { 110 int USBDevice::claimInterface(const libusb_interface_descriptor *interfaceDescriptor, int endpointOut, int endPointIn) {
105 int errorCode = libusb_claim_interface(this->handle, interfaceDescriptor->bInterfaceNumber); 111 int errorCode = libusb_claim_interface(this->handle, interfaceDescriptor->bInterfaceNumber);
@@ -135,7 +141,9 @@ void USBDevice::disconnectFromDevice() { @@ -135,7 +141,9 @@ void USBDevice::disconnectFromDevice() {
135 } 141 }
136 this->handle = nullptr; 142 this->handle = nullptr;
137 143
  144 +#if !defined(_WIN32) || !defined(_WIN64)
138 libusb_unref_device(device); 145 libusb_unref_device(device);
  146 +#endif
139 147
140 emit deviceDisconnected(); 148 emit deviceDisconnected();
141 } 149 }
readme.md
1 -# OpenHantek [![Build Status](https://travis-ci.org/OpenHantek/openhantek.svg?branch=master)](https://travis-ci.org/OpenHantek/openhantek) [![Build status](https://ci.appveyor.com/api/projects/status/9w4rd5r04ufqafr4/branch/master?svg=true)](https://ci.appveyor.com/project/davidgraeff/openhantek/branch/master) [![Stability: Maintenance](https://masterminds.github.io/stability/maintenance.svg)](https://masterminds.github.io/stability/maintenance.html) 1 +# OpenHantek [![Build Status](https://travis-ci.org/OpenHantek/openhantek.svg?branch=master)](https://travis-ci.org/OpenHantek/openhantek) [![Build status](https://ci.appveyor.com/api/projects/status/github/openhantek/openhantek?branch=master&svg=true)](https://ci.appveyor.com/project/openhantek/openhantek/branch/master) [![Stability: Maintenance](https://masterminds.github.io/stability/maintenance.svg)](https://masterminds.github.io/stability/maintenance.html)
2 2
3 OpenHantek is a free software for Hantek and compatible (Voltcraft/Darkwire/Protek/Acetech) USB digital signal oscilloscopes. 3 OpenHantek is a free software for Hantek and compatible (Voltcraft/Darkwire/Protek/Acetech) USB digital signal oscilloscopes.
4 4