diff options
author | Andre Hartmann <aha_1980@gmx.de> | 2020-02-26 13:57:11 +0100 |
---|---|---|
committer | André Hartmann <aha_1980@gmx.de> | 2020-02-27 09:59:34 +0000 |
commit | b63877157c2c9681ced1efbfefe1d2d1debf812e (patch) | |
tree | fb28b028f839cac311f2a7572374b74added86fe /examples/serialbus/can/mainwindow.h | |
parent | 245f9f299a3503fa9acc54517fa9bd541366d7cc (diff) |
CAN-Example: Fix two issues with the status timer
1. Fix a crash when device open fails
If opening of m_canDevice failed, m_canDevice is reset to
nullptr in line 154. Dereferencing that leads to a crash.
2. Avoid connecting multiple slots to status timer
Opening and closing multiple times lead to multiple
connections of the lambda slot, which triggered the
call to m_canDevice->busStatus() unnecessarily often.
The solution is to do the connection only once,
and stop the timer when m_canDevice becomes nullptr.
It is started again after a successful open.
Amends f83587a9978bd212d
[ChangeLog][Examples] Fixed a crash in CAN-Example when
opening the CAN bus device failed.
Change-Id: I4d19f382593fa26fa3b8166f7121e7ff14fd2e74
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/serialbus/can/mainwindow.h')
-rw-r--r-- | examples/serialbus/can/mainwindow.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/examples/serialbus/can/mainwindow.h b/examples/serialbus/can/mainwindow.h index 2e910d1..febe72d 100644 --- a/examples/serialbus/can/mainwindow.h +++ b/examples/serialbus/can/mainwindow.h @@ -82,6 +82,7 @@ private slots: void sendFrame(const QCanBusFrame &frame) const; void processErrors(QCanBusDevice::CanBusError) const; void connectDevice(); + void busStatus(); void disconnectDevice(); void processFramesWritten(qint64); |