After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 97729 - ScrolledWindow: Warning during destruction.
ScrolledWindow: Warning during destruction.
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.0
Other other
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on: 98413
Blocks: 97996
 
 
Reported: 2002-11-05 13:56 UTC by Matthew Tuck
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test.cc - slightly cleaned-up test code. (282 bytes, text/plain)
2002-11-06 10:53 UTC, Murray Cumming
  Details
gtkmm_c_containers_qdata.patch (3.09 KB, patch)
2002-11-14 01:50 UTC, Murray Cumming
none Details | Review

Description Matthew Tuck 2002-11-05 13:56: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;

}
Comment 1 Murray Cumming 2002-11-06 10:53:50 UTC
Created attachment 12088 [details]
test.cc - slightly cleaned-up test code.
Comment 2 Murray Cumming 2002-11-06 10:56:13 UTC
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. 
Comment 3 Matthew Tuck 2002-11-06 14:41:48 UTC
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.
Comment 4 Murray Cumming 2002-11-09 17:32:06 UTC
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.
Comment 5 Murray Cumming 2002-11-10 14:33:44 UTC
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.
Comment 6 Murray Cumming 2002-11-13 23:33:01 UTC
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.
Comment 7 Murray Cumming 2002-11-14 01:50:21 UTC
Created attachment 12298 [details] [review]
gtkmm_c_containers_qdata.patch
Comment 8 Murray Cumming 2002-11-14 02:12:34 UTC
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.