Re: Glib::Object and Gtk::Window multiple inheritance



Am 07.10.2012 18:21, schrieb Horváth Imre:
> Hi!
> 
> I want to create a base class for my window and dialog classes, the
> structure looks lik this:
> 
> class Base : public Glib::Object
[...]
> 
> class WindowBase : public Base, public Gtk::Window
[...]
> 
> class DialogBase : public Base, public Gtk::Dialog
[...]
> 
> class MyWindow : public WindowBase
[...]

> 
> When i want to instantiate the MyWindow, I get the following error:
> glibmm:ERROR:objectbase.cc:78:void
> Glib::ObjectBase::initialize(GObject*): assertion failed: (gobject_ ==
> castitem)
> 
> I think it's because the multiple inheritance of Glib::Object from Base
> and from Gtk::Window, but I can not find a solution.
> 

Please look at [1] and [2]. Adding virtual inheritance of Glib::Object
should fix your problem.

[1] http://en.wikipedia.org/wiki/Diamond_problem#The_diamond_problem
[2] http://en.wikipedia.org/wiki/Virtual_inheritance

Regards,
Florian Philipp

Attachment: signature.asc
Description: OpenPGP digital signature



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