Gtk::CellRendererPixbuf criticals - is this a GTKmm bug?

Inkscape has been spewing this message ever since the GTK4 port:

GLib-GObject-CRITICAL **: unable to set property 'pixbuf' of type 'GdkPixbuf' from value of type 'glibmm__CustomBoxed_St10shared_ptrIN3Gdk6PixbufEE'

Even weirder, it only happens when the software is packaged as an AppImage, or on Windows. The regular Linux build works just fine. (This could be due to them using different versions of GTKmm.)

I isolated it to the following rather innocuous code, which I don’t think is doing anything wrong:

// combobox: Gtk::Combobox *
// renderer: Gtk::CellRendererPixbuf *
// col_pixbuf: Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf>>
combobox->add_attribute(*renderer, "pixbuf", col_pixbuf);

It looks like GTKmm is forgetting to unwrap the C++ type to the underlying C type, but how can that happen?

glibmm__CustomBoxed_St10shared_ptrIN3Gdk6PixbufEE is not the Gtype name
of the C++ wrapper of GdkPixbuf. I’d expect gtkmm__GdkPixbuf.
Something is wrong. I can’t say if the bug is in glibmm, gtkmm or Inkscape.
Is it possible that the correct declaration of Gdk::Pixbuf is not in view where
col_pixbuf is created?

The offending line in context is here: combo-tool-item.cpp#L160.

Gdk::Pixbuf is indeed not in view, only forward-declared, at the point where col_pixbuf is created.

Could that cause this sort of problem?

I made a small test where the most interesting lines are

namespace Gdk { class Pixbuf; }
std::cout << g_type_name(Glib::Value<Glib::RefPtr<Gdk::Pixbuf>>::value_type()) << std::endl;

The output is glibmm__CustomBoxed_St10shared_ptrIKN3Gdk6PixbufEE.

An identical call to Glib::Value<>::value_type() is made in the constructor of
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf>>.
The solution is to add #include <gdkmm/pixbuf.h> in the file where
col_pixbuf is created. It’s unfortunate that the compiler does not report
this as an error.

Thanks @kjellahl, adding #include <gdkmm/pixbuf.h> solved it!

A have made a fix in glibmm that changes
Glib::Value<Glib::RefPtr<Gdk::Pixbuf>>::value_type() from a run-time error
to a compile-time error when Gdk::Pixbuf is an incomplete class type (forward declared).

Let’s hope that no one complains, calling this an API-break. I don’t know if it is.
A program that could be compiled previously (but did not work correctly)
can’t be compiled now.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.