Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Games: Fix crash on game close after controller disconnects #14676
This fixes a crash that occurs when a controller is disconnected before gameplay ends, such as a wireless controller running out of batteries.
The crash occurs because CKeymapHandling unregisters itself with the peripheral object when destructed. However, if the peripheral was unplugged and the object deleted, then CKeymapHandling tries to unregister itself with the dangling pointer.
To fix this, we preemptively set CKeymapHandling:: m_inputProvider to null when we detect that the peripheral no longer exists. Then, on destruction, we can do a null check to avoid accessing a dangling pointer.
Motivation and Context
Batteries died... things went boom.
How Has This Been Tested?
Tested on OSX by yanking the batteries from my Xbox 360 controller. No more crash on game close.
Types of change