Просмотр исходного кода

Fixed two cases where joystick/haptic objects should be marked invalid on error during open.

Sam Lantinga 3 недель назад
Родитель
Сommit
452c3634d4
2 измененных файлов с 2 добавлено и 0 удалено
  1. 1 0
      src/haptic/SDL_haptic.c
  2. 1 0
      src/joystick/hidapi/SDL_hidapijoystick.c

+ 1 - 0
src/haptic/SDL_haptic.c

@@ -367,6 +367,7 @@ SDL_Haptic *SDL_OpenHapticFromJoystick(SDL_Joystick *joystick)
         if (SDL_HIDAPI_JoystickIsHaptic(joystick)) {
             if (!SDL_HIDAPI_HapticOpenFromJoystick(haptic, joystick)) {
                 SDL_SetError("Haptic: SDL_HIDAPI_HapticOpenFromJoystick failed.");
+                SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, false);
                 SDL_free(haptic);
                 SDL_UnlockJoysticks();
                 return NULL;

+ 1 - 0
src/joystick/hidapi/SDL_hidapijoystick.c

@@ -950,6 +950,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
         }
 
         if (!device->name) {
+            SDL_SetObjectValid(device, SDL_OBJECT_TYPE_HIDAPI_JOYSTICK, false);
             SDL_free(device->manufacturer_string);
             SDL_free(device->product_string);
             SDL_free(device->serial);