Bug #624

Gtk backend warning: g_thread_init is deprected

Added by Zbigniew Rebacz almost 7 years ago. Updated almost 7 years ago.

Status:ApprovedStart date:12/30/2013
Priority:NormalDue date:
Assignee:Zbigniew Rebacz% Done:

0%

Category:CtrlCoreSpent time:-
Target version:-

Description

It seems that we use deprected gtk function for initializing threads. After 2.32 gtk version, multithreading is enable by default.

So we need to check gtk version to avoid this warning (GtkApp.cpp - line 29):

#if GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 32
    if(!g_thread_supported())
        g_thread_init(NULL);
#endif

GtkApp.cpp Magnifier (1.35 KB) Zbigniew Rebacz, 12/30/2013 06:57 PM

History

#1 Updated by Miroslav Fidler almost 7 years ago

  • Status changed from Patch ready to Approved

#2 Updated by Zbigniew Rebacz almost 7 years ago

  • Status changed from Approved to Patch ready

Can we change #if statement to more readable:

#if GTK_CHECK_VERSION(2, 32, 0)
    if(!g_thread_supported())
        g_thread_init( NULL );
#endif

#3 Updated by Miroslav Fidler almost 7 years ago

  • Status changed from Patch ready to In Progress
  • Assignee changed from Miroslav Fidler to Zbigniew Rebacz

I believe that proposed change is wrong. Should not it be rather

#if !GTK_CHECK_VERSION(2, 32, 0)

?

#4 Updated by Miroslav Fidler almost 7 years ago

(speaking of which, original patch is wrong as well, think about version 1.40...:)

#5 Updated by Zbigniew Rebacz almost 7 years ago

  • Status changed from In Progress to Patch ready
  • Assignee changed from Zbigniew Rebacz to Miroslav Fidler

Sorry for the mess.

I don't know why following expresion: "#if !GTK_CHECK_VERSION(2, 32, 0)" is alwayse true on my platform (latest Kubuntu version). I have glib version: 2.38.1.

I think we should change this to:

#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 32) || (GLIB_MAJOR_VERSION == 1) 

This solution should alwayes work.

#6 Updated by Miroslav Fidler almost 7 years ago

Zbigniew Rebacz wrote:

Sorry for the mess.

I don't know why following expresion: "#if !GTK_CHECK_VERSION(2, 32, 0)" is alwayse true on my platform (latest Kubuntu version). I have glib version: 2.38.1.

That indeed is weird, I think you should try to resolve that first, just to be sure we understand the damned macro correctly... Have you tried something like

GUI_APP_MAIN
{
    DDUMP(GTK_CHECK_VERSION(2, 19, 0));
    DDUMP(!GTK_CHECK_VERSION(2, 19, 0));
    DDUMP(GTK_CHECK_VERSION(1, 19, 0));
    DDUMP(!GTK_CHECK_VERSION(1, 19, 0));
    DDUMP(GTK_CHECK_VERSION(2, 30, 0));
    DDUMP(!GTK_CHECK_VERSION(2, 30, 0));
}

?

#7 Updated by Zbigniew Rebacz almost 7 years ago

Here is output:

((2) > (2) || ((2) == (2) && (24) > (19)) || ((2) == (2) && (24) == (19) && (20) >= (0))) = true
!((2) > (2) || ((2) == (2) && (24) > (19)) || ((2) == (2) && (24) == (19) && (20) >= (0))) = false
((2) > (1) || ((2) == (1) && (24) > (19)) || ((2) == (1) && (24) == (19) && (20) >= (0))) = true
!((2) > (1) || ((2) == (1) && (24) > (19)) || ((2) == (1) && (24) == (19) && (20) >= (0))) = false
((2) > (2) || ((2) == (2) && (24) > (30)) || ((2) == (2) && (24) == (30) && (20) >= (0))) = false
!((2) > (2) || ((2) == (2) && (24) > (30)) || ((2) == (2) && (24) == (30) && (20) >= (0))) = true

#8 Updated by Miroslav Fidler almost 7 years ago

Hm, it looks like you have either 2.24, or have some glitch in include paths...

#9 Updated by Miroslav Fidler almost 7 years ago

  • Status changed from Patch ready to In Progress
  • Assignee changed from Miroslav Fidler to Zbigniew Rebacz

#10 Updated by Zbigniew Rebacz almost 7 years ago

  • Assignee changed from Zbigniew Rebacz to Miroslav Fidler

Now, I understand the origin of this issue. Let's execute following test case:

GUI_APP_MAIN 
{
    String gtkVersion  = (IntStr(GTK_MAJOR_VERSION) + "." + IntStr(GTK_MINOR_VERSION) + "." + IntStr(GTK_MICRO_VERSION));
    String glibVersion = (IntStr(GLIB_MAJOR_VERSION) + "." + IntStr(GLIB_MINOR_VERSION) + "." + IntStr(GLIB_MICRO_VERSION));

    DDUMP(gtkVersion);
    DDUMP(glibVersion);
}

The output is:

gtkVersion = 2.24.20
glibVersion = 2.38.1

Personally, I don't know what we are going to do with this results. Should we replace GTK with GLIB?

#11 Updated by Miroslav Fidler almost 7 years ago

Ops :)

Well, GLIB_CHECK_VERSION really exists. Can you check with that?

Mirek

#12 Updated by Miroslav Fidler almost 7 years ago

  • Assignee changed from Miroslav Fidler to Zbigniew Rebacz

#13 Updated by Zbigniew Rebacz almost 7 years ago

  • Assignee changed from Zbigniew Rebacz to Miroslav Fidler

Your test case results with GLIB_CHECK_VERSION macro:

(2 > (2) || (2 == (2) && 38 > (19)) || (2 == (2) && 38 == (19) && 1 >= (0))) = true
!(2 > (2) || (2 == (2) && 38 > (19)) || (2 == (2) && 38 == (19) && 1 >= (0))) = false
(2 > (1) || (2 == (1) && 38 > (19)) || (2 == (1) && 38 == (19) && 1 >= (0))) = true
!(2 > (1) || (2 == (1) && 38 > (19)) || (2 == (1) && 38 == (19) && 1 >= (0))) = false
(2 > (2) || (2 == (2) && 38 > (30)) || (2 == (2) && 38 == (30) && 1 >= (0))) = true
!(2 > (2) || (2 == (2) && 38 > (30)) || (2 == (2) && 38 == (30) && 1 >= (0))) = false

****************************************************
No warning while using following code:

#if !GLIB_CHECK_VERSION(2, 32, 0)
    if(!g_thread_supported())
        g_thread_init(NULL);
#endif

P.S.
GLIB_CHECK_VERSION documentation: https://developer.gnome.org/glib/2.30/glib-Version-Information.html

Btw, shouldn't we replace GTK_CHECK_VERSION with GLIB_CHECK_VERSION in other cases like DnD too?

#14 Updated by Miroslav Fidler almost 7 years ago

  • Status changed from In Progress to Approved
  • Assignee changed from Miroslav Fidler to Zbigniew Rebacz

Btw, shouldn't we replace GTK_CHECK_VERSION with GLIB_CHECK_VERSION in other cases like DnD too?

Definitely not, these are really gtk/gdk versions (which is the same).

Well, all seems OK now, closing the task. Thanks for cooperation.

Also available in: Atom PDF