summaryrefslogtreecommitdiffstats
path: root/examples/serialbus/can/mainwindow.h
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2019-11-08 22:31:14 +0100
committerAndre Hartmann <aha_1980@gmx.de>2019-11-21 21:01:56 +0100
commite333d015458b579768ca229918a3ed426f0e4029 (patch)
tree921e63de39ae759a9808d4919dec396f3c6d3572 /examples/serialbus/can/mainwindow.h
parent545494c6e7c2441f7fc8c6b7e337189461938b00 (diff)
CAN Example: Don't destroy QCanBusDevice after disconnect
The old code could already called the destructor of the CAN plugin while the disconnect process was still running. Using deleteLater() does not help much here, e.g. the VirtualCAN plugin needs to send "disconnect" packets and then close the TCP connection afterwards. By using a unique_ptr we can keep the object alive until the program ends or the connection dialog is opened to set up a new connection. By this delay and the usage of deleteLater(), the plugin has enough time to properly shut down. Change-Id: I9e992a4b954acd82d62d058000d2108d975b1e9c Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/serialbus/can/mainwindow.h')
-rw-r--r--examples/serialbus/can/mainwindow.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/serialbus/can/mainwindow.h b/examples/serialbus/can/mainwindow.h
index 673e87a..2e910d1 100644
--- a/examples/serialbus/can/mainwindow.h
+++ b/examples/serialbus/can/mainwindow.h
@@ -96,7 +96,7 @@ private:
QLabel *m_status = nullptr;
QLabel *m_written = nullptr;
ConnectDialog *m_connectDialog = nullptr;
- QCanBusDevice *m_canDevice = nullptr;
+ std::unique_ptr<QCanBusDevice> m_canDevice;
QTimer *m_busStatusTimer = nullptr;
};