If commands are buffered and not sent when the device is disconnected, call any completion callbacks.

This is to guarantee that completion callbacks are always called, so if any
resource collection happens in them it'll always happen.
master
Glenn Maynard 6 years ago
parent 135e3c5401
commit 4691ce5ecf
  1. 13
      sdk/Windows/SMXDeviceConnection.cpp

@ -56,6 +56,19 @@ void SMX::SMXDeviceConnection::Close()
if(m_hDevice)
CancelIo(m_hDevice->value());
// If we're being closed while a command was in progress, call its completion
// callback, so it's guaranteed to always be called.
if(m_pCurrentCommand && m_pCurrentCommand->m_pComplete)
m_pCurrentCommand->m_pComplete();
// If any commands were queued with completion callbacks, call their completion
// callbacks.
for(auto &pendingCommand: m_aPendingCommands)
{
if(pendingCommand->m_pComplete)
pendingCommand->m_pComplete();
}
m_hDevice.reset();
m_sReadBuffers.clear();
m_aPendingCommands.clear();

Loading…
Cancel
Save