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."
    3e0fbb22c0

[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
This commit is contained in:
Mike Fleetwood 2018-12-24 09:52:15 +00:00 committed by Curtis Gedak
parent 8df975c7d1
commit 80d6394684
3 changed files with 5 additions and 10 deletions

View File

@ -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

View File

@ -17,13 +17,12 @@
#include "GParted_Core.h"
#include "Win_GParted.h"
#include <glibmm.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/main.h>
int main( int argc, char *argv[] )
{
//initialize thread system
Glib::thread_init() ;
GParted::GParted_Core::mainthread = Glib::Thread::self();
Gtk::Main kit( argc, argv ) ;

View File

@ -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();
}