Skip to content

Commit

Permalink
Fix macos crash on launch when output=surface or auto
Browse files Browse the repository at this point in the history
  • Loading branch information
maron2000 committed Sep 12, 2023
1 parent 9c68132 commit 61da2e6
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/gui/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ extern int tryconvertcp, Reflect_Menu(void);
#include <output/output_tools.h>
#include <output/output_ttf.h>
#include <output/output_tools_xbrz.h>
static bool init_output = false;

#if defined(WIN32)
#include "resource.h"
Expand Down Expand Up @@ -3714,7 +3715,13 @@ static void GUI_StartUp() {
sdl.desktop.isperfect = false; /* Reset before selection */
if (output == "surface")
{
#if C_DIRECT3D
if(!init_output) OUTPUT_DIRECT3D_Select();
#elif C_OPENGL
if(!init_output) OUTPUT_OPENGL_Select(GLBilinear); // Initialize screen before switching to TTF (required for macOS builds)
#endif
OUTPUT_SURFACE_Select();
init_output = true;
#if C_OPENGL
}
else if (output == "opengl" || output == "openglhq")
Expand Down Expand Up @@ -3749,18 +3756,25 @@ static void GUI_StartUp() {
else if (output == "ttf")
{
LOG_MSG("SDL(sdlmain.cpp): TTF activated");
#if C_OPENGL
OUTPUT_OPENGL_Select(GLBilinear); // Initialize screen before switching to TTF (required for macOS builds)
#if C_DIRECT3D
if(!init_output) OUTPUT_DIRECT3D_Select();
#elif C_OPENGL
if(!init_output) OUTPUT_OPENGL_Select(GLBilinear); // Initialize screen before switching to TTF (required for macOS builds)
#else
OUTPUT_SURFACE_Select();
#endif // C_OPENGL
#endif // C_DIRECT3D || C_OPENGL
OUTPUT_TTF_Select(0);
init_output = true;
}
#endif
else
{
LOG_MSG("SDL: Unsupported output device %s, switching back to surface",output.c_str());
#if MACOSX && C_OPENGL
if(!init_output) OUTPUT_OPENGL_Select(GLBilinear); // Initialize screen before switching to surface (required for macOS builds)
#endif
OUTPUT_SURFACE_Select(); // should not reach there anymore
init_output = true;
}

sdl.overscan_width=(unsigned int)section->Get_int("overscan");
Expand Down

0 comments on commit 61da2e6

Please sign in to comment.