Call XInitThreads() in posix frontend

XInitThreads() is needed in multi-threading X applications when multiple
threads try to access the Xlib. Add the call to the three frontends in
posix/ and add the required autoconf-stuff, too.
This commit is contained in:
Ingo Saitz 2018-06-27 21:14:05 +02:00 committed by zeromus
parent 23f4dcc009
commit 0e86cf128d
7 changed files with 25 additions and 2 deletions

View File

@ -5,4 +5,4 @@ AM_CPPFLAGS += $(SDL_CFLAGS) $(ALSA_CFLAGS) $(LIBAGG_CFLAGS) $(GLIB_CFLAGS) $(GT
bin_PROGRAMS = desmume-cli
desmume_cli_SOURCES = main.cpp ../shared/sndsdl.cpp ../shared/ctrlssdl.h ../shared/ctrlssdl.cpp
desmume_cli_LDADD = ../libdesmume.a $(SDL_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS) $(LIBSOUNDTOUCH_LIBS)
desmume_cli_LDADD = ../libdesmume.a $(X_LIBS) -lX11 $(SDL_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS) $(LIBSOUNDTOUCH_LIBS)

View File

@ -18,6 +18,7 @@
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <X11/Xlib.h>
#include <SDL.h>
#include <SDL_thread.h>
#include <stdlib.h>
@ -641,6 +642,12 @@ int main(int argc, char ** argv) {
execute = true;
/* X11 multi-threading support */
if(!XInitThreads())
{
fprintf(stderr, "Warning: X11 not thread-safe\n");
}
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1)
{
fprintf(stderr, "Error trying to initialize SDL: %s\n",

View File

@ -53,6 +53,9 @@ AC_CHECK_LIB(zzip, zzip_open, [
AC_MSG_RESULT(no))
])
dnl - Check for X11
AC_PATH_X
dnl - Check for SDL
AC_PATH_PROGS(SDLCONFIG, [sdl-config sdl11-config])
if test ! "x$SDLCONFIG" = "x" ; then

View File

@ -31,6 +31,7 @@ desmume_glade_SOURCES = \
../../../driver.h ../../../driver.cpp
desmume_glade_LDADD = ../libdesmume.a \
$(X_LIBS) -lX11 \
$(SDL_LIBS) $(GTKGLEXT_LIBS) $(LIBGLADE_LIBS) \
$(GTHREAD_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) \
$(LIBSOUNDTOUCH_LIBS)

View File

@ -533,6 +533,12 @@ int main(int argc, char *argv[]) {
init_configured_features( &my_config);
/* X11 multi-threading support */
if(!XInitThreads())
{
fprintf(stderr, "Warning: X11 not thread-safe\n");
}
if (!g_thread_supported())
g_thread_init( NULL);

View File

@ -25,7 +25,7 @@ desmume_SOURCES = \
cheatsGTK.h cheatsGTK.cpp \
main.cpp main.h
desmume_LDADD = ../libdesmume.a \
$(SDL_LIBS) $(GTK_LIBS) $(GTHREAD_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) $(LIBSOUNDTOUCH_LIBS)
$(X_LIBS) -lX11 $(SDL_LIBS) $(GTK_LIBS) $(GTHREAD_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) $(LIBSOUNDTOUCH_LIBS)
if HAVE_LIBOSMESA
desmume_LDADD += $(OSMESA_LIBS)
else

View File

@ -3505,6 +3505,12 @@ int main (int argc, char *argv[])
my_config.parse(argc, argv);
init_configured_features( &my_config);
/* X11 multi-threading support */
if(!XInitThreads())
{
fprintf(stderr, "Warning: X11 not thread-safe\n");
}
if (!g_thread_supported())
g_thread_init( NULL);