Re: Gtk::Builder::get_widget_derived() Issue on Fedora 33

Kjell Ahlstedt via gtkmm-list <[email protected]> Tue, 17 Nov 2020 15:51:02 +0100
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <[email protected]>
wrap_init.cc contains the following lines:

// Disable the 'const' function attribute of the get_type() functions.
// GCC would optimize them out because we don't use the return value.
#undef  G_GNUC_CONST
#define G_GNUC_CONST /* empty */

This has so far made sure that the compiler does not optimize out the 
calls to the get_type() functions.
@Andrew, do you think this will not be so with very new compilers? I've 
used gcc 9.3.0.

Kjell

On 2020-11-17 09:37, Andrew Potter wrote:
>
> On Tue, Nov 17, 2020 at 12:01 AM ahmet öztürk <[email protected] 
> <mailto:[email protected]>> wrote:
>
>     Is this a Gtkmm issue then? Fedora guys also think that it is an
>     upstream issue.
>     See:https://bugzilla.redhat.com/show_bug.cgi?id=1898054
>
>     But why does it only occur on Fedora 33?
>
> Likely its due to a new optimization in gcc 10 which few other distros 
> are using yet.
> Since the GtkFoo::get_type() calls in wrap_init() are not using the 
> return value, it makes sense to me that they are eligible for dead 
> code elimination, as is suggested in the blog post. Since Gtkmm is 
> calling these methods explicitly to ensure the GTypes are made known, 
> I think fixing it in Gtkmm by adding g_type_ensure() is the path of 
> least resistance.
>
>     @Andrew, I do not know how I am supposed to use
>     g_type_ensure(TVDerived::get_type()). I am not familiar with Gtk+
>     or GObject, I have only used Gtkmm, so far.
>
>
> You can simply replace TVDerived dummy; with 
> g_type_ensure(TVDerived::get_type()); in your example program.
>
> For a more professional look, you can define an init() function that 
> calls g_type_ensure() for all of your custom derived types and call it 
> in main()--but I guess you should explicitly call 
> Gtk::Main::init_gtkmm_internals() before your init() ala 
> https://developer.gnome.org/gtkmm-tutorial/stable/sec-wrapping-initialization.html.en
>

_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list