Fixed an issue where buggy controller drivers could crash the application.

This commit is contained in:
Leon Styhre 2021-12-10 16:51:41 +01:00
parent bd3ec2472e
commit 55316365d8
2 changed files with 7 additions and 0 deletions

View file

@ -129,6 +129,7 @@ Apart from all the above, a huge amount of work has gone into fixing bugs, refac
* Single-scraping a game, aborting and then re-scraping without leaving the metadata editor would sometimes lead to a crash
* Setting a really small font size in a theme would crash the application
* Deleting the last custom collection could crash the application if the grouped "collections" system was set as the startup gamelist
* Connecting a controller with buggy drivers could crash the application
* Setting an invalid UIMode value in the configuration file could crash the application
* Setting an invalid scraper service value in the configuration file could crash the application
* When scraping in interactive mode with "Auto-accept single game matches" enabled, the game name could not be refined if there were no games found

View file

@ -625,6 +625,12 @@ void InputManager::addControllerByDeviceIndex(Window* window, int deviceIndex)
{
// Open joystick and add it to our list.
SDL_GameController* controller = SDL_GameControllerOpen(deviceIndex);
if (controller == nullptr) {
LOG(LogError) << "Couldn't add controller with device index " << deviceIndex;
return;
}
SDL_Joystick* joy = SDL_GameControllerGetJoystick(controller);
// Add it to our list so we can close it again later.