summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/canbus/vectorcan/vectorcanbackend.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/plugins/canbus/vectorcan/vectorcanbackend.cpp b/src/plugins/canbus/vectorcan/vectorcanbackend.cpp
index 289eaea..6c455da 100644
--- a/src/plugins/canbus/vectorcan/vectorcanbackend.cpp
+++ b/src/plugins/canbus/vectorcan/vectorcanbackend.cpp
@@ -171,6 +171,7 @@ bool VectorCanBackendPrivate::open()
if (Q_UNLIKELY(status != XL_SUCCESS || portHandle == XL_INVALID_PORTHANDLE)) {
q->setError(systemErrorString(status), QCanBusDevice::ConnectionError);
+ portHandle = XL_INVALID_PORTHANDLE;
return false;
}
}
@@ -211,6 +212,11 @@ void VectorCanBackendPrivate::close()
delete writeNotifier;
writeNotifier = nullptr;
+ // xlClosePort can crash on systems with vxlapi.dll but no device driver installed.
+ // Therefore avoid calling any close function when the portHandle is invalid anyway.
+ if (portHandle == XL_INVALID_PORTHANDLE)
+ return;
+
{
const XLstatus status = ::xlDeactivateChannel(portHandle, channelMask);
if (Q_UNLIKELY(status != XL_SUCCESS)) {