Fixed crash when disconnecting external display on iOS

This commit is contained in:
Sam Lantinga 2024-07-05 15:51:20 -07:00
parent e559b271b5
commit 753f3f8609
2 changed files with 5 additions and 4 deletions

View file

@ -48,7 +48,7 @@ extern SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen);
extern int UIKit_InitModes(SDL_VideoDevice *_this);
#ifndef SDL_PLATFORM_VISIONOS
extern int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event);
extern void UIKit_DelDisplay(UIScreen *uiscreen);
extern void UIKit_DelDisplay(UIScreen *uiscreen, SDL_bool send_event);
#endif
extern int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
extern int UIKit_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);

View file

@ -92,7 +92,7 @@
+ (void)screenDisconnected:(NSNotification *)notification
{
UIScreen *uiscreen = [notification object];
UIKit_DelDisplay(uiscreen);
UIKit_DelDisplay(uiscreen, SDL_TRUE);
}
@end
@ -308,7 +308,7 @@ int UIKit_AddDisplay(SDL_bool send_event){
#ifndef SDL_PLATFORM_VISIONOS
void UIKit_DelDisplay(UIScreen *uiscreen)
void UIKit_DelDisplay(UIScreen *uiscreen, SDL_bool send_event)
{
SDL_DisplayID *displays;
int i;
@ -321,7 +321,8 @@ void UIKit_DelDisplay(UIScreen *uiscreen)
if (data && data.uiscreen == uiscreen) {
CFRelease(display->driverdata);
SDL_DelVideoDisplay(displays[i], SDL_FALSE);
display->driverdata = NULL;
SDL_DelVideoDisplay(displays[i], send_event);
break;
}
}