* @brief Non-virtual cleanup implementation shared by close() and ~Modbus(). */
| 239 | * @brief Non-virtual cleanup implementation shared by close() and ~Modbus(). |
| 240 | */ |
| 241 | void IO::Drivers::Modbus::doClose() |
| 242 | { |
| 243 | if (m_pollTimer) |
| 244 | m_pollTimer->stop(); |
| 245 | |
| 246 | if (m_lastReply) { |
| 247 | disconnect(m_lastReply, nullptr, this, nullptr); |
| 248 | m_lastReply->deleteLater(); |
| 249 | m_lastReply = nullptr; |
| 250 | } |
| 251 | |
| 252 | if (m_device) { |
| 253 | disconnect(m_device, nullptr, this, nullptr); |
| 254 | |
| 255 | if (m_device->state() != QModbusDevice::UnconnectedState) |
| 256 | m_device->disconnectDevice(); |
| 257 | |
| 258 | m_device->deleteLater(); |
| 259 | m_device = nullptr; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * @brief Returns true when the Modbus device is connected. |
nothing calls this directly
no test coverage detected