Skip to content

Commit

Permalink
Fix crash on exit when using nvidia-460 + SDL with EGL support
Browse files Browse the repository at this point in the history
  • Loading branch information
LBPHacker committed Apr 6, 2021
1 parent 4e5527c commit b98c9c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/PowderToyFontEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,17 @@ int main(int argc, char * argv[])
ui::Engine::Ref().CloseWindow();
delete gameController;
delete ui::Engine::Ref().g;
if (SDL_GetWindowFlags(sdl_window) & SDL_WINDOW_OPENGL)
{
// * nvidia-460 egl registers callbacks with x11 that end up being called
// after egl is unloaded unless we grab it here and release it after
// sdl closes the display. this is an nvidia driver weirdness but
// technically an sdl bug. glfw has this fixed:
// https://github.com/glfw/glfw/commit/9e6c0c747be838d1f3dc38c2924a47a42416c081
SDL_GL_LoadLibrary(NULL);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_GL_UnloadLibrary();
}
SDL_Quit();
return 0;
}
11 changes: 11 additions & 0 deletions src/PowderToySDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,17 @@ int main(int argc, char * argv[])
delete gameController;
delete ui::Engine::Ref().g;
Client::Ref().Shutdown();
if (SDL_GetWindowFlags(sdl_window) & SDL_WINDOW_OPENGL)
{
// * nvidia-460 egl registers callbacks with x11 that end up being called
// after egl is unloaded unless we grab it here and release it after
// sdl closes the display. this is an nvidia driver weirdness but
// technically an sdl bug. glfw has this fixed:
// https://github.com/glfw/glfw/commit/9e6c0c747be838d1f3dc38c2924a47a42416c081
SDL_GL_LoadLibrary(NULL);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_GL_UnloadLibrary();
}
SDL_Quit();
return 0;
}

0 comments on commit b98c9c8

Please sign in to comment.