Fix potential deadlock in RdpConnection destructor

The destructor only called peer->Close() when state was Streaming, but the run thread could be blocked in WaitForMultipleObjects in other states too (e.g. Running). This caused thread.join() to deadlock because the thread was waiting for socket events that would never arrive.

Fix by always calling peer->Close() when the peer exists, regardless of state, to unblock the run thread's event wait.

Also guard onClose() against being called twice, which can happen when the destructor calls peer->Close() which triggers onClose(), and then the destructor's thread cleanup path triggers it again.

Tested with: Windows 11 mstsc → KDE Plasma 6.6.1 (Wayland)

Merge request reports

Loading