diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 10 | ||||
-rw-r--r-- | include/nm-glib-compat.h | 34 | ||||
-rw-r--r-- | tui/newt/Makefile.am | 1 | ||||
-rw-r--r-- | tui/newt/nmt-newt-types.h | 1 | ||||
-rw-r--r-- | tui/newt/nmt-newt-utils.c | 11 |
6 files changed, 52 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am index edeadf56a5..b41bfa90f1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,7 +57,7 @@ cscope: cscope -b -q -R -Iinclude -ssrc -slibnm-glib -slibnm-util -scli/src; libgsystem_srcpath := libgsystem -libgsystem_cflags := $(GLIB_CFLAGS) -I$(srcdir)/libgsystem +libgsystem_cflags := $(filter-out -DGLIB_VERSION%,$(GLIB_CFLAGS)) -I$(srcdir)/libgsystem libgsystem_libs = $(GLIB_LIBS) include libgsystem/Makefile-libgsystem.am noinst_LTLIBRARIES = libgsystem.la diff --git a/configure.ac b/configure.ac index 9e29b715da..174b6bfa20 100644 --- a/configure.ac +++ b/configure.ac @@ -254,12 +254,10 @@ AM_CONDITIONAL(HAVE_DBUS_GLIB_100, test "${have_dbus_glib_100}" = "yes") PKG_CHECK_MODULES(GLIB, gio-unix-2.0 >= 2.32 gmodule-2.0) dnl GLIB_VERSION_MIN_REQUIRED should match the version above. -dnl GLIB_VERSION_MAX_ALLOWED should be the largest version for which there -dnl is a GLIB_CHECK_VERSION check. We currently have to use -dnl G_ENCODE_VERSION(2,34) here rather than GLIB_VERSION_2_34, because -dnl GLib 2.32 did not handle future version defines correctly. - -GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32 '-DGLIB_VERSION_MAX_ALLOWED=G_ENCODE_VERSION(2,34)'" +dnl GLIB_VERSION_MAX_ALLOWED should be set to the same version; +dnl nm-glib-compat.h will cause it to be overridden for the functions +dnl we have compat versions of. +GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32" AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) diff --git a/include/nm-glib-compat.h b/include/nm-glib-compat.h index 58e92cfea2..9004e241c0 100644 --- a/include/nm-glib-compat.h +++ b/include/nm-glib-compat.h @@ -55,6 +55,40 @@ g_type_ensure (GType type) _destroy (_p); \ } G_STMT_END +/* These are used to clean up the output of test programs; we can just let + * them no-op in older glib. + */ +#define g_test_expect_message(log_domain, log_level, pattern) +#define g_test_assert_expected_messages() + +#else + +/* We build with -DGLIB_MAX_ALLOWED_VERSION set to 2.32 to make sure we don't + * accidentally use new API that we shouldn't. But we don't want warnings for + * the APIs that we emulate above. + */ + +#define g_type_ensure(t) \ + G_STMT_START { \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_type_ensure (t); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } G_STMT_END + +#define g_test_expect_message(domain, level, format...) \ + G_STMT_START { \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_test_expect_message (domain, level, format); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } G_STMT_END + +#define g_test_assert_expected_messages_internal(domain, file, line, func) \ + G_STMT_START { \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_test_assert_expected_messages_internal (domain, file, line, func); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } G_STMT_END + #endif #endif /* NM_GLIB_COMPAT_H */ diff --git a/tui/newt/Makefile.am b/tui/newt/Makefile.am index c5b295cade..7dc35bb0fb 100644 --- a/tui/newt/Makefile.am +++ b/tui/newt/Makefile.am @@ -1,4 +1,5 @@ AM_CPPFLAGS= \ + -I$(top_srcdir)/include \ $(GLIB_CFLAGS) \ $(NEWT_CFLAGS) \ $(NULL) diff --git a/tui/newt/nmt-newt-types.h b/tui/newt/nmt-newt-types.h index c26ff900ef..608f7ff6fa 100644 --- a/tui/newt/nmt-newt-types.h +++ b/tui/newt/nmt-newt-types.h @@ -21,6 +21,7 @@ #include <glib-object.h> #include <newt.h> +#include "nm-glib-compat.h" G_BEGIN_DECLS diff --git a/tui/newt/nmt-newt-utils.c b/tui/newt/nmt-newt-utils.c index 028c2438c6..10e8484927 100644 --- a/tui/newt/nmt-newt-utils.c +++ b/tui/newt/nmt-newt-utils.c @@ -26,6 +26,7 @@ #include <errno.h> #include <stdarg.h> #include <unistd.h> +#include <sys/wait.h> #include <glib/gi18n-lib.h> @@ -350,11 +351,21 @@ nmt_newt_edit_string (const char *data) goto done; } +#if GLIB_CHECK_VERSION (2, 34, 0) + G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (!g_spawn_check_exit_status (status, &error)) { nmt_newt_message_dialog (_("Editor failed: %s"), error->message); g_error_free (error); goto done; } + G_GNUC_END_IGNORE_DEPRECATIONS +#else + if (WIFEXITED (status)) { + if (WEXITSTATUS (status) != 0) + nmt_newt_message_dialog (_("Editor failed with status %d"), WEXITSTATUS (status)); + } else if (WIFSIGNALED (status)) + nmt_newt_message_dialog (_("Editor failed with signal %d"), WTERMSIG (status)); +#endif if (!g_file_get_contents (filename, &new_data, NULL, &error)) { nmt_newt_message_dialog (_("Could not re-read file: %s"), error->message); |