WiimoteReal: Fix crash on real Wii Remote disconnect on Windows caused by dangling pointer.

This commit is contained in:
Jordan Woyak 2021-01-20 17:23:56 -06:00
parent 4705af59c6
commit bb2c50ac94
1 changed files with 3 additions and 1 deletions

View File

@ -916,7 +916,9 @@ static void TryToConnectBalanceBoard(std::unique_ptr<Wiimote> wm)
static void HandleWiimoteDisconnect(int index)
{
Core::RunAsCPUThread([index] {
g_wiimotes[index] = nullptr;
// The Wii Remote object must exist through the call to UpdateSource
// to prevent WiimoteDevice from having a dangling HIDWiimote pointer.
const auto temp_real_wiimote = std::move(g_wiimotes[index]);
WiimoteCommon::UpdateSource(index);
});
}