GNOME Bugzilla – Bug 97729
ScrolledWindow: Warning during destruction.
Last modified: 2004-12-22 21:47:04 UTC
Another warning and crash when deleting widgets: (a.out:13137): Gtk-CRITICAL **: file gtkcontainer.c: line 878 (gtk_container_remove): assertion `GTK_IS_CONTAINER (container)' failed I think this might be new since bug #95606 was resolved fixed. Code: #include <gtkmm.h> class Instance { public: Gtk::Frame widget_frame; Gtk::ScrolledWindow widget_scroll; Instance() { widget_scroll.add( widget_frame ); } }; int main ( int argc, char *argv[] ) { Gtk::Main main( argc, argv ); Instance *instance = new Instance(); delete instance; }
Created attachment 12088 [details] test.cc - slightly cleaned-up test code.
Note that this only happens when the parent is a Gtk::ScrolledWindow. However, we haven't seen this before in any examples so hopefully this warning doesn't happen when the ScrolledWindow is added to a container.
This definitely *does* happen when the ScrolledWindow was added to a container, adding it makes no difference and so was simplified out of the test case.
I have added this test code to the tests directory. This problem doesn't happen when the child is a Gtk::TreeView, so it seems to be caused by the use of gtk_scrolled_window_add_with_viewport() inside Gtk::ScrolledWindow::add() - I suspect that GtkScrolledWindow should use a weak reference somewhere and I'm trying to write some GTK+ code to prove it.
I was wrong. gtk_scrolled_window_add_with_viewport() adds a GtkViewport, then puts the widget in that. But only gtkmm containers don't destroy their children. Sent mail to gtk-devel list with a possible solution. We can fix this as a one-off, but I'd like a more general gtkmm-widgets-inside-GTK+-containers solution.
Here is an imperfect patch that works with the GTK+ patch and fixes the problem. It doesn't look like the GTK+ patch will be approved, which might be awful. But Daniel has another idea, involving overriding the dispose vfunc, so I'll try that too.
Created attachment 12298 [details] [review] gtkmm_c_containers_qdata.patch
OK, I _think_ this is fixed in CVS without needing to change GTK+. Please test and confirm, and watch out for any other lifetime problems that it might cause.