mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Drop XInitThreads workaround
GTK used by wxWidgets on Unix calls it when creating an X11 window as does SDL. As such this is no longer needed and we avoid a direct dependency on X11. Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
8a999d63b7
commit
1a1340182f
2 changed files with 9 additions and 41 deletions
|
|
@ -122,14 +122,6 @@
|
|||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
|
||||
#if !(OS_WIN || OS_MACOSX || OS_ANDROID) // assume all other platforms use X11 for wxWidgets
|
||||
#define MUST_INIT_X11 1
|
||||
#include <X11/Xlib.h>
|
||||
#else
|
||||
#define MUST_INIT_X11 0
|
||||
#endif
|
||||
|
||||
extern void RestartEngine();
|
||||
|
||||
using namespace std::literals;
|
||||
|
|
@ -514,17 +506,6 @@ void EarlyInit()
|
|||
|
||||
FixLocales();
|
||||
|
||||
// Because we do GL calls from a secondary thread, Xlib needs to
|
||||
// be told to support multiple threads safely.
|
||||
// This is needed for Atlas, but we have to call it before any other
|
||||
// Xlib functions (e.g. the ones used when drawing the main menu
|
||||
// before launching Atlas)
|
||||
#if MUST_INIT_X11
|
||||
int status = XInitThreads();
|
||||
if (status == 0)
|
||||
debug_printf("Error enabling thread-safety via XInitThreads\n");
|
||||
#endif
|
||||
|
||||
// Initialise the low-quality rand function
|
||||
srand(time(NULL)); // NOTE: this rand should *not* be used for simulation!
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
|
|
@ -53,10 +53,6 @@
|
|||
#error libxml2 must have threading support enabled
|
||||
#endif
|
||||
|
||||
#ifdef __WXGTK__
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
// If enabled, we'll try to use wxDebugReport to report fatal exceptions.
|
||||
// But this is broken on Linux and can cause the UI to deadlock (see comment
|
||||
// in OnFatalException), and it's never especially useful, so don't use it.
|
||||
|
|
@ -139,18 +135,6 @@ ATLASDLLIMPEXP void Atlas_StartWindow(const wchar_t* type)
|
|||
// (If we're executed from the game instead, it has the responsibility to initialise libxml2)
|
||||
LIBXML_TEST_VERSION
|
||||
|
||||
g_InitialWindowType = type;
|
||||
#ifdef __WXMSW__
|
||||
wxEntry(g_Module);
|
||||
#else
|
||||
#ifdef __WXGTK__
|
||||
// Because we do GL calls from a secondary thread, Xlib needs to
|
||||
// be told to support multiple threads safely
|
||||
int status = XInitThreads();
|
||||
if (status == 0)
|
||||
{
|
||||
fprintf(stderr, "Error enabling thread-safety via XInitThreads\n");
|
||||
}
|
||||
#if defined(wxUSE_GLCANVAS_EGL) && wxUSE_GLCANVAS_EGL == 0
|
||||
// The glcanvas is currently either built with support for GLX or EGL, if
|
||||
// built with GLX support on Wayland we need to use XWayland.
|
||||
|
|
@ -164,13 +148,17 @@ ATLASDLLIMPEXP void Atlas_StartWindow(const wchar_t* type)
|
|||
wxSetEnv("GDK_BACKEND", "x11");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
g_InitialWindowType = type;
|
||||
#ifdef __WXMSW__
|
||||
wxEntry(g_Module);
|
||||
#else
|
||||
int argc = 1;
|
||||
char atlas[] = "atlas";
|
||||
char *argv[] = {atlas, NULL};
|
||||
#ifndef __WXOSX__
|
||||
# ifndef __WXOSX__
|
||||
wxEntry(argc, argv);
|
||||
#else
|
||||
# else
|
||||
// Fix for OS X init (see https://gitea.wildfiregames.com/0ad/0ad/issues/2427 )
|
||||
// If we launched from in-game, SDL started NSApplication which will
|
||||
// break some things in wxWidgets
|
||||
|
|
@ -179,8 +167,7 @@ ATLASDLLIMPEXP void Atlas_StartWindow(const wchar_t* type)
|
|||
wxTheApp->OnRun();
|
||||
wxTheApp->OnExit();
|
||||
wxEntryCleanup();
|
||||
#endif
|
||||
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue