Commit 03759ccf authored by deuce's avatar deuce
Browse files

Uninitialize SDL video before trying to initialize any other video output.

This fixes the Linux crash on exit in SDL when X11 mode is used (and possible
others).
parent e0599ad5
......@@ -52,6 +52,7 @@
#if defined(WITH_SDL) || defined(WITH_SDL_AUDIO)
#include "sdl_con.h"
#include "sdlfuncs.h"
#endif
#ifdef _WIN32
#include "win32cio.h"
......@@ -168,6 +169,11 @@ int try_sdl_init(int mode)
#ifndef NO_X
int try_x_init(int mode)
{
#if defined(WITH_SDL) || defined(WITH_SDL_AUDIO)
if (sdl_video_initialized)
sdl.QuitSubSystem(SDL_INIT_VIDEO);
#endif
if(!x_init()) {
cio_api.mode=CIOLIB_MODE_X;
cio_api.mouse=1;
......@@ -205,6 +211,11 @@ int try_x_init(int mode)
int try_curses_init(int mode)
{
#if defined(WITH_SDL) || defined(WITH_SDL_AUDIO)
if (sdl_video_initialized)
sdl.QuitSubSystem(SDL_INIT_VIDEO);
#endif
if(curs_initciolib(mode)) {
if(mode==CIOLIB_MODE_AUTO)
mode=CIOLIB_MODE_CURSES;
......@@ -233,6 +244,11 @@ int try_curses_init(int mode)
int try_ansi_init(int mode)
{
#if defined(WITH_SDL) || defined(WITH_SDL_AUDIO)
if (sdl_video_initialized)
sdl.QuitSubSystem(SDL_INIT_VIDEO);
#endif
if(ansi_initciolib(mode)) {
cio_api.mode=CIOLIB_MODE_ANSI;
cio_api.mouse=0;
......@@ -257,6 +273,11 @@ int try_ansi_init(int mode)
#endif
int try_conio_init(int mode)
{
#if defined(WITH_SDL) || defined(WITH_SDL_AUDIO)
if (sdl_video_initialized)
sdl.QuitSubSystem(SDL_INIT_VIDEO);
#endif
/* This should test for something or other */
if(win32_initciolib(mode)) {
if(mode==CIOLIB_MODE_AUTO)
......
......@@ -25,7 +25,7 @@ struct sdlfuncs sdl;
static int sdl_funcs_loaded=0;
static int sdl_initialized=0;
static int sdl_audio_initialized=0;
static int sdl_video_initialized=0;
int sdl_video_initialized=0;
static int (*sdl_drawing_thread)(void *data)=NULL;
static void (*sdl_exit_drawing_thread)(void)=NULL;
static int main_returned=0;
......
......@@ -79,6 +79,7 @@ struct sdlfuncs {
/* Defined in SDL_win32_main.c for Win32 */
extern struct sdlfuncs sdl;
extern SDL_sem *sdl_exit_sem;
extern int sdl_video_initialized;
#ifdef __cplusplus
extern "C" {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment