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



One quick follow-up. I re-read [this page][1] about initialization and realized that I didn't generate or call a `wrap_init` function using `generate_wrap_init.pl`. So I added that step and am now calling it in `main()` before any using code. This means that I was previously not calling the following:

~~~
  Glib::wrap_register(gtk_panzoom_area_get_type(),
                      &PanZoomArea_Class::wrap_new);

~~~

Unfortunately even after generating the `wrap_init` and calling it in my `main()` I continue to get the same error and cannot load the widget with `Gtk::Builder`. Also, since I forgot to mention this before, I'm using gtkmm version 3.22.2 and glibmm 2.56.0 (as distributed with Ubuntu 18.04). 

[1]: https://developer.gnome.org/gtkmm-tutorial/stable/sec-wrapping-initialization.html.en

On Fri, May 1, 2020 at 3:48 PM Josh Bialkowski <josh bialkowski gmail com> wrote:
Ok, thanks for trying to help! I'll take a look at the generated code for something in gtkmm and see if it's any different with regard to ObjectBase initialization. 

On Fri, May 1, 2020 at 3:44 PM Daniel Boles via gtkmm-list <gtkmm-list gnome org> wrote:


On Fri, 1 May 2020, 23:40 Josh Bialkowski, <josh bialkowski gmail com> wrote:
It looks like it does, I'm pretty sure this happens in the `panzoomarea_class_.init()` call:
~~~
PanZoomArea::PanZoomArea()
    :  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
      Glib::ObjectBase(nullptr),
      Gtk::DrawingArea(Glib::ConstructParams(panzoomarea_class_.init())) {}


iirc for Builder to work with derived widgets, ObjectBase() needs called with a type name or id. but not sure it explains dynamic_cast failing, so i'll defer to someone more experienced now!

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]