From 80d6394684c8276ea99ee97545e4dc7fc8b050b4 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Mon, 24 Dec 2018 09:52:15 +0000 Subject: [PATCH] Remove deprecated Glib::thread_init() (!22) Use of Glib::thread_init() was deprecated in glibmm 2.32 [1]. The oldest supported distributions have these versions: Debian 8 glibmm 2.42.0 RHEL / CentOS 7 glibmm 2.56.0 SLES 12 glibmm 2.38.1 Ubuntu 14.04 LTS glibmm 2.39.93 Checking further the glibmm 2.32 reference manual says this about Glib::thread_init() [2]: Initializes the GLib thread system. Deprecated: Calling thread_init() is no longer necessary and no longer has any effect. However only some of the glibmm example programs had Glib::thread_init() removed, others had it replaced by Glib::init() [3]. Again the glibmm 2.32 reference manual says this about Glib::init() [4]: Initialize glibmm. You may call this more than once. You do not need to call this if you are using Glib::MainLoop or Gtk::Main, because they call it for you. GParted does call Gtk::Main and test_PipeCapture does call Glib::MainLoop. Therefore just raise the minimum version to glibmm 2.32 and remove both calls to Glib::thread_init(). [1] Glibmm 2.32 NEWS file https://gitlab.gnome.org/GNOME/glibmm/blob/2.32.0/NEWS#L207 [2] glibmm 2.32, glibmm: Glib Namespace Reference, Glib::thread_init() https://developer.gnome.org/glibmm/2.32/namespaceGlib.html#ab26d01c776801f1fff00753e97af4fc7 [3] glibmm commit "Avoid use of deprecates API in tests and examples." https://gitlab.gnome.org/GNOME/glibmm/commit/3e0fbb22c0d4814de4174d32e12a45cbad79980e [4] glibmm 2.32, glibmm: Glib Namespace Reference, Glib::init() https://developer.gnome.org/glibmm/2.32/namespaceGlib.html#ac90aee10d0b90e3d8a96a86b5394f87b Closes !22 - Increase minimums to libparted 2.2 and glibmm 2.32 --- configure.ac | 2 +- src/main.cc | 3 +-- tests/test_PipeCapture.cc | 10 +++------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index c9a21065..bd5d145c 100644 --- a/configure.ac +++ b/configure.ac @@ -205,7 +205,7 @@ AC_SUBST([GTKMM_CFLAGS]) dnl Check for glibmm minimum required version. -PKG_CHECK_MODULES([GLIBMM], [glibmm-2.4 >= 2.14.0]) +PKG_CHECK_MODULES([GLIBMM], [glibmm-2.4 >= 2.32.0]) need_cxx_compile_stdcxx_11=no diff --git a/src/main.cc b/src/main.cc index d3583175..2c37ec99 100644 --- a/src/main.cc +++ b/src/main.cc @@ -17,13 +17,12 @@ #include "GParted_Core.h" #include "Win_GParted.h" +#include #include #include int main( int argc, char *argv[] ) { - //initialize thread system - Glib::thread_init() ; GParted::GParted_Core::mainthread = Glib::Thread::self(); Gtk::Main kit( argc, argv ) ; diff --git a/tests/test_PipeCapture.cc b/tests/test_PipeCapture.cc index 3a8882fe..886ea7fc 100644 --- a/tests/test_PipeCapture.cc +++ b/tests/test_PipeCapture.cc @@ -412,18 +412,14 @@ TEST_F( PipeCaptureTest, LineDisciplineSkipCtrlAB ) } // namespace GParted -// Custom Google Test main() which also initialises the Glib threading system for -// distributions with glib/glibmm before version 2.32. -// References: +// Custom Google Test main(). +// Reference: // * Google Test, Primer, Writing the main() Function -// * Deprecated thread API, g_thread_init() -// https://developer.gnome.org/glib/stable/glib-Deprecated-Thread-APIs.html#g-thread-init +// https://github.com/google/googletest/blob/master/googletest/docs/primer.md#writing-the-main-function int main( int argc, char **argv ) { printf("Running main() from %s\n", __FILE__ ); testing::InitGoogleTest( &argc, argv ); - Glib::thread_init(); - return RUN_ALL_TESTS(); }