X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdevices%2Fhardwaredevice.cpp;h=953864d589429fb9fb1c20e05d106de5132f55f9;hp=6374dafe6e03aaddb219a05c1fa4c3a21ab71dd5;hb=b961bf17ba19203193ab70598ca53312520af99d;hpb=b485408f20c39ae8d05372a5faffe15653c74705 diff --git a/pv/devices/hardwaredevice.cpp b/pv/devices/hardwaredevice.cpp index 6374dafe..953864d5 100644 --- a/pv/devices/hardwaredevice.cpp +++ b/pv/devices/hardwaredevice.cpp @@ -43,12 +43,15 @@ namespace devices { HardwareDevice::HardwareDevice(const std::shared_ptr &context, std::shared_ptr device) : - context_(context) { + context_(context), + device_open_(false) { device_ = device; } HardwareDevice::~HardwareDevice() { - device_->close(); + if (device_open_) + device_->close(); + if (session_) session_->remove_devices(); } @@ -104,6 +107,8 @@ void HardwareDevice::create() { throw QString(e.what()); } + device_open_ = true; + // Set up the session session_ = context_->create_session(); session_->add_device(device_);