mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
Android: concurrency issue for Android_SetWindowFullscreen()
It accesses data->native_window, which can be changed by onNativeSurfacedChanged(). Currently, Android_SetWindowFullscreen() may access data->native_window after it has been released, and before a new reference is acquired. (can be reproduced by adding some SDL_Delay() in onNativeSurfacedChanged and Android_SetWindowFullscreen() ).
This commit is contained in:
parent
59df6d6b13
commit
1803944bb2
@ -116,6 +116,10 @@ Android_SetWindowTitle(_THIS, SDL_Window *window)
|
|||||||
void
|
void
|
||||||
Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
|
Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
|
||||||
{
|
{
|
||||||
|
SDL_LockMutex(Android_ActivityMutex);
|
||||||
|
|
||||||
|
if (window == Android_Window) {
|
||||||
|
|
||||||
/* If the window is being destroyed don't change visible state */
|
/* If the window is being destroyed don't change visible state */
|
||||||
if (!window->is_destroying) {
|
if (!window->is_destroying) {
|
||||||
Android_JNI_SetWindowStyle(fullscreen);
|
Android_JNI_SetWindowStyle(fullscreen);
|
||||||
@ -128,13 +132,13 @@ Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display
|
|||||||
* still not be the full display size.
|
* still not be the full display size.
|
||||||
*/
|
*/
|
||||||
if (!SDL_IsDeXMode() && !SDL_IsChromebook()) {
|
if (!SDL_IsDeXMode() && !SDL_IsChromebook()) {
|
||||||
return;
|
goto endfunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||||
|
|
||||||
if (!data || !data->native_window) {
|
if (!data || !data->native_window) {
|
||||||
return;
|
goto endfunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
int old_w = window->w;
|
int old_w = window->w;
|
||||||
@ -146,6 +150,11 @@ Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display
|
|||||||
if (old_w != new_w || old_h != new_h) {
|
if (old_w != new_w || old_h != new_h) {
|
||||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, new_w, new_h);
|
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, new_w, new_h);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endfunction:
|
||||||
|
|
||||||
|
SDL_UnlockMutex(Android_ActivityMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user