On 2020-07-25 17:35, Carlo Wood wrote:
Why would this core dump??

LinuxChessboardWidget is defined as:

class LinuxChessboardWidget : public cwmm::ChessPositionWidget, public 
Gio::ActionMap
{
   ...

I have to derive from Gio::ActionMap because its constructor is protected.
The call to `add_action` above is to that class.

Can someone tell me what I'm doing wrong?

Carlo

Gio::ActionMap is an interface. That's why its constructor is protected. An interface can't be instantiated by itself. It must be implemented by a class which can be instantiated. If you really must implement Gio::ActionMap in your class (which I doubt), there is one or (probably) two errors.

First, interfaces must come before the widget class in the list of base classes.

class LinuxChessboardWidget : public Gio::ActionMap, public 
cwmm::ChessPositionWidget

This is opposite to what's done in gtkmm's classes that wrap gtk classes.

Second, your constructor must call a special Glib::ObjectBase constructor that 
registers your class with its own GType in glib's GType system. For instance

LinuxChessboardWidget(......) : Glib::ObjectBase("myWidgetClass") ..... // Or 
whatever you want to call it.

This is an unusual way of using Gio::ActionMap. I don't know if these are the 
only necessary changes. Much more common is to use one of the classes that 
already implement Gio::ActionMap: Gio::SimpleActionGroup, Gtk::Application (via 
Gio::Application) or Gtk::ApplicationWindow.

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

Reply via email to