Re: Builder derived widgets with properties -- error validate_and_install_class_property: assertion 'class->set_property != NULL' failed

2022-08-30 Thread Dan Lo Forte

Kjell,

That worked! Thanks!

Dan

On 8/30/22 08:06, Kjell Ahlstedt wrote:

Den 2022-08-29 kl. 23:37, skrev Dan Lo Forte:


I have a glade file from which I load a derived widget that has a 
Glib::Property.  When I load the main window, I get the following error:


```

GLib-GObject-CRITICAL **: validate_and_install_class_property: 
assertion 'class->set_property != NULL' failed


```

I have created a simplified example, as per this page: 
https://developer-old.gnome.org/gtkmm-tutorial/stable/sec-builder-using-derived-widgets.html.en, 
using a derived Gtk::Button and still see the error.



Your simplified example is very similar to the example at 
https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/tree/gtkmm-3-24/examples/book/builder/derived, 
which does not print an error message. There is a significant 
difference in the glade file (glade_str). You shall change GtkButton 
to gtkmm__CustomObject_DerivedButtonProp, the Gtype name of your 
button class.

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


Re: Builder derived widgets with properties -- error validate_and_install_class_property: assertion 'class->set_property != NULL' failed

2022-08-30 Thread Kjell Ahlstedt via gtkmm-list

Den 2022-08-29 kl. 23:37, skrev Dan Lo Forte:


I have a glade file from which I load a derived widget that has a 
Glib::Property.  When I load the main window, I get the following error:


```

GLib-GObject-CRITICAL **: validate_and_install_class_property: 
assertion 'class->set_property != NULL' failed


```

I have created a simplified example, as per this page: 
https://developer-old.gnome.org/gtkmm-tutorial/stable/sec-builder-using-derived-widgets.html.en, 
using a derived Gtk::Button and still see the error.



Your simplified example is very similar to the example at 
https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/tree/gtkmm-3-24/examples/book/builder/derived, 
which does not print an error message. There is a significant difference 
in the glade file (glade_str). You shall change GtkButton to 
gtkmm__CustomObject_DerivedButtonProp, the Gtype name of your button class.

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


Builder derived widgets with properties -- error validate_and_install_class_property: assertion 'class->set_property != NULL' failed

2022-08-29 Thread Dan Lo Forte
I have a glade file from which I load a derived widget that has a 
Glib::Property.  When I load the main window, I get the following error:


```

GLib-GObject-CRITICAL **: validate_and_install_class_property: assertion 
'class->set_property != NULL' failed


```

I have created a simplified example, as per this page: 
https://developer-old.gnome.org/gtkmm-tutorial/stable/sec-builder-using-derived-widgets.html.en, 
using a derived Gtk::Button and still see the error.


I have included Glib::ObjectBase() in the initializer list of the 
derived widget and called the default constructor which also has a the 
Glib::ObjectBase() to initialize the Gtype (), but I still see the error.



Additionally, the property appears to work, in that I can connect to the 
signal_changed and set/get the property value as expected, but still 
receive the error at runtime.



Simplified example:

```

#include  #include  Glib::ustring glade_str =
"\n" "\n" "\n" " lib=\"gtk+\"version=\"3.24\"/>\n" " class=\"GtkWindow\"id=\"mainwindow\">\n" " name=\"can-focus\">False\n" " \n" " class=\"GtkButton\"id=\"btn\">\n" " name=\"label\"translatable=\"yes\">button\n" " name=\"visible\">True\n" " name=\"can-focus\">True\n" " name=\"receives-default\">True\n" " \n" " 
\n" " \n" ""; class DerivedButtonProp :public Gtk::Button {

public:
static void ensure_type()
{
std::cout<< __PRETTY_FUNCTION__ << std::endl; 
static_cast(DerivedButtonProp()); }

DerivedButtonProp(BaseObjectType *obj, Glib::RefPtr const 
)
:Glib::ObjectBase(s_type_name), Gtk::Button(obj), prop_mynum(*this, 
"mynumprop")
{
std::cout<< __PRETTY_FUNCTION__ << std::endl; }

virtual ~DerivedButtonProp() =default; Glib::PropertyProxy mynum() 
{return prop_mynum.get_proxy(); }; private:
DerivedButtonProp()
:Glib::ObjectBase(s_type_name), prop_mynum(*this, "mynumprop")
{
std::cout<< __PRETTY_FUNCTION__ << std::endl; }; static constexpr auto s_type_name 
="DerivedButtonProp"; Glib::Property prop_mynum; }; class App :public Gtk::Window {
public:
App()
{

}

App(BaseObjectType *obj, Glib::RefPtr const & builder)
:Gtk::Window(obj)
{
builder->get_widget_derived("btn", btn_derprop); }

virtual ~App() =default; protected:
DerivedButtonProp *btn_derprop =nullptr; }; App* pWindow =nullptr; 
Glib::RefPtr app; int main(int argc, char *argv[])
{
Glib::RefPtr app = Gtk::Application::create(); DerivedButtonProp::ensure_type(); 
Glib::RefPtr builder = Gtk::Builder::create_from_string(glade_str); App *pWindow 
=nullptr; builder->get_widget_derived("mainwindow", pWindow); app->run(*pWindow); }

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