Re: gtkmm-4: Widget wrappers can't be deleted like in gtkmm-3

2018-02-12 Thread Kjell Ahlstedt

On Fri, 1 Dec 2017 13:35:01 +0100


Kjell Ahlstedt  wrote:

Changes in gtk+-4 make it impossible to delete C++ widget wrappers
like it's done in Gtk::Object::~Object() and
Gtk::Object::_release_c_instance(). See
https://bugzilla.gnome.org/show_bug.cgi?id=773642#c20. How can we do
it in gtkmm-4? Comments ans suggestions are welcome.

I guess one approach is to retain the Gtk::Widget/Gtk::Window class for
top level widgets, on which gtk_widget_destroy() can be called with the
correct result, and to manage everything else by operating only on the
GObject reference count (as with Glib::RefPtr) and by adding and
removing widgets from their containers.  That is essentially (and
somewhat fortuitously) what a wrapper of my own which I sometimes use
does, and what (as I understand it) C code is supposed to do with GTK+4.

It would however give rise to a fearsome amount of work and a complete
redesign of the interfaces, which I imagine would not be welcome to
gtkmm users.

Chris


There may be an easier fix. See 
https://bugzilla.gnome.org/show_bug.cgi?id=773642#22.

  Gtk::Object::_release_c_instance(): Don't release if in a container

  Don't release the C instance, if it's a widget in a container widget.
  Just steal the GQuark that points from the C instance to the C++ wrapper,
  and accept that a new wrapper is later created, if necessary.
  Nowadays it's difficult to know which container the widget has been added to.
  It's not necessarily the one returned by gtk_widget_get_parent().
  Bug 773642 comments 20-22. See also gtk+ bug 786048 comment 5.

With this patch all demo programs run without segfault and without messages 
that relate
to destruction of C instances.

Kjell

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


Re: gtkmm-4: Widget wrappers can't be deleted like in gtkmm-3

2017-12-01 Thread Chris Vine
On Fri, 1 Dec 2017 13:35:01 +0100
Kjell Ahlstedt  wrote:
> Changes in gtk+-4 make it impossible to delete C++ widget wrappers
> like it's done in Gtk::Object::~Object() and 
> Gtk::Object::_release_c_instance(). See 
> https://bugzilla.gnome.org/show_bug.cgi?id=773642#c20. How can we do
> it in gtkmm-4? Comments ans suggestions are welcome.

I guess one approach is to retain the Gtk::Widget/Gtk::Window class for
top level widgets, on which gtk_widget_destroy() can be called with the
correct result, and to manage everything else by operating only on the
GObject reference count (as with Glib::RefPtr) and by adding and
removing widgets from their containers.  That is essentially (and
somewhat fortuitously) what a wrapper of my own which I sometimes use
does, and what (as I understand it) C code is supposed to do with GTK+4.

It would however give rise to a fearsome amount of work and a complete
redesign of the interfaces, which I imagine would not be welcome to
gtkmm users.

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