I think the cause is the G_GNUC_CONST annotation on TextView::get_type().

When I step through the code on Fedora 33, in Gtk::wrap_init, all the
wrap_registers happen, but the function just returns, skipping the calls to
e.g. TextView::get_type()

Ahmet can use g_type_ensure(TVDerived::get_type()) rather than default
constructing the class.

I think the best fix would be to wrap all the GtkFoo::get_type() calls in
Gtk::wrap_init with g_type_ensure. See
https://blogs.gnome.org/mcatanzaro/2015/09/14/your-_get_type-function-is-not-g_gnuc_const/

On Sun, Nov 15, 2020 at 11:56 PM ahmet öztürk via gtkmm-list <
gtkmm-list@gnome.org> wrote:

> Hi Kjell,
>
> Thank you for the response. I tried your suggestion and the outputs were
> exactly as you guessed. So, this seems like a Fedora specific issue. I will
> be filing a bug report there.
>
> Kjell Ahlstedt <kjellahlst...@gmail.com>, 15 Kas 2020 Paz, 15:19
> tarihinde şunu yazdı:
>
>> On 2020-11-14 14:56, ahmet öztürk via gtkmm-list wrote:
>> > Hi all,
>> >
>> > On Fedora 33, derived widgets does not seem to be constructed properly
>> > by Gtk::Builder::get_widget_derived(). The reason I think so is that
>> > the overridden methods are not called for these widgets. Apart from
>> > that everything seems normal. No error message or anything.
>> >
>> > I attached a sample code with a very simple case to replicate this
>> > problem. on_button_press_event() is never called for the derived widget.
>> >
>> > I have also noticed that if a dummy instance of the derived widget is
>> > created separately (using another constructor) before calling
>> > Gkt::Builder::add_from_string(), then the widget created by Builder
>> > also works normally.
>> >
>> > Please note that this may not occur on all distributions. e.g. I know
>> > that it does not occur on Arch Linux.
>> >
>> > Does anybody know if this a Fedora 33 specific issue or is it due to a
>> > recent update in Gtkmm that is only affecting Fedora for now?
>> >
>> The issue does not occur on Ubuntu 20.04 with the latest gtk+3 and
>> gtkmm3 from the git repo.
>>
>> It looks as if the gtkmm__GtkTextView class has not been registered in
>> the GType system before get_widget_derived() is called. That should have
>> been done by Gtk::wrap_init() which is called from
>> Gtk::Application::create().
>>
>> You can test if I'm right. Add
>>     std::cout << "GType name: " <<
>> G_OBJECT_TYPE_NAME(m_TextView->gobj()) << std::endl;
>> after the call to get_widget_derived(). When the overloaded function is
>> not called, I suspect that the output will be
>>     GType name: GtkTextView
>> When you've uncommented TVDerived dummy;, and everything is okay, the
>> output is probably
>>    GType name: gtkmm__GtkTextView
>>
>> If I'm right, it looks like a Fedora specific issue. It can't be due to
>> a recent update in gtkmm (I've tested with the very latest one), unless
>> there is some Fedora specific update.
>>
>> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtkmm-list
>
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to