From 9df711bda03419b3a68e22b43d7b32f2963617a2 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 16 Jun 2010 16:59:16 +0200 Subject: [PATCH] Ensure that psppire's --help and --version options work even without an X server. --- src/ui/gui/automake.mk | 4 ++++ src/ui/gui/main.c | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 4774e2ae..038b2cf2 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -273,3 +273,7 @@ BUILT_SOURCES += src/ui/gui/psppire-marshal.c src/ui/gui/psppire-marshal.h CLEANFILES += src/ui/gui/psppire-marshal.c src/ui/gui/psppire-marshal.h \ $(nodist_src_ui_gui_psppire_DATA) endif HAVE_GUI + +#ensure the installcheck passes even if there is no X server available +installcheck-local: + DISPLAY=/invalid/port $(MAKE) $(AM_MAKEFLAGS) installcheck-binPROGRAMS diff --git a/src/ui/gui/main.c b/src/ui/gui/main.c index eddf3fe3..a5e054f0 100644 --- a/src/ui/gui/main.c +++ b/src/ui/gui/main.c @@ -262,11 +262,12 @@ main (int argc, char *argv[]) g_warning ("%s", vers); } - /* Let GDK remove any options that it owns. */ - gdk_init (&argc, &argv); - /* Parse our own options. */ ss = create_source_stream (); + /* Parse our own options. + This must come BEFORE gdk_init otherwise options such as + --help --version which ought to work without an X server, won't. + */ parser = argv_parser_create (); argv_parser_add_options (parser, startup_options, N_STARTUP_OPTIONS, startup_option_callback, &show_splash); @@ -275,6 +276,11 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); argv_parser_destroy (parser); + /* Initialise GDK. Theoretically this call can remove options from argc,argv if + it thinks they are gdk options. + However there shouldn't be any here because of the gtk_parse_args call above. */ + gdk_init (&argc, &argv); + init_p.splash_window = create_splash_window (); init_p.ss = ss; init_p.data_file = optind < argc ? argv[optind] : NULL; -- 2.30.2