Re: Cannot `dynamic_cast` custom wrapped widget from Gtk::Builder

Kjell Ahlstedt via gtkmm-list <[email protected]> Tue, 5 May 2020 09:05:27 +0200
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <[email protected]>
On 2020-05-04 23:45, Josh Bialkowski wrote:
> > You said in a previous post that you execute...
>
> Wellllll... this is executed inside the generated `wrap_init()` which 
> is part of the `Gtk::` namespace (in hindsight, a bad idea) and 
> apparently this function is not getting called. If I call it directly 
> in `main()` then things are working. At first, I thought there must be 
> a `Gtk::wrap_init()` somewhere already in gtkmm but I can't find it, 
> so the other possibility is maybe a build system error and a left over 
> build artifact somewhere. Maybe? In any case, to summarize, my 
> understanding is that:
>
> 1. I used _CLASS_GOBJECT which generates a Glib::wrap returning a 
> `Glib::RefPtr` instead of _CLASS_GTKOBJECT which generates Glib::wrap 
> returning a raw pointer. This may or may not have contributed to the 
> particular problem, as perhaps some type/overload resolution somewhere 
> depended on this. Or it was a latent error that wasn't involved in 
> this particular problem.
> 2. Lacking a `wrap_init`, I was not calling `Glib::wrap_register`, 
> which sounds like the most likely culprit
> 3. Even after I generated `wrap_init()`, it apparently wasn't getting 
> called. Possibly due to some link-order issue or a stale build 
> artifact or something.
>
Gtk::wrap_init() is called from Gtk::Main (deprecated) and from 
Gtk::Application.

Have you created your own Gtk::wrap_init(), containing everything the 
standard Gtk::wrap_init() contains, plus your own Glib::wrap_register() 
call? In that case I suppose there are two Gtk::wrap_init() functions, 
one in libgtkmm-3.0 and another one in your lib file. Which one will the 
linker select?