can't remove a widget correctly from a Gtk::ScrolledWindow

Bug #1055744 reported by Jonas Platte
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gtkmm3.0 (Ubuntu)
New
Undecided
Unassigned

Bug Description

I've got a little program that should change the content in the left area when an item in a TreeView on the left side of the window is clicked. Everything worked well, until I changed the right areas base container to a ScrolledWindow. Now, when I remove a widget from the right area, and afterwards - somewhen in the runtime - change back to it, it can't be added anymore. I get the error

Gtk-CRITICAL **: gtk_scrolled_window_add_with_viewport: assertion `gtk_widget_get_parent (child) == NULL' failed

I've found a bug report for something that seems to be the same, but in gtkmm 2.4: https://bugs.launchpad.net/ubuntu/+source/gtkmm2.4/+bug/30345

I've got a code sample as attachment that shows the problem. You can also see it when you compile my program yourself (It's available on github: https://github.com/jonessen96/SchoolMessOrganizer)

ProblemType: Bug
DistroRelease: Ubuntu 12.10
Package: libgtkmm-3.0-dev 3.5.12-0ubuntu3
ProcVersionSignature: Ubuntu 3.5.0-15.22-generic 3.5.4
Uname: Linux 3.5.0-15-generic x86_64
ApportVersion: 2.5.2-0ubuntu4
Architecture: amd64
Date: Mon Sep 24 21:36:26 2012
InstallationMedia: Ubuntu 12.10 "Quantal Quetzal" - Alpha amd64+mac (20120905.2)
ProcEnviron:
 PATH=(custom, no user)
 LANG=de_DE.UTF-8
 SHELL=/bin/bash
SourcePackage: gtkmm3.0
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Jonas Platte (jplatte) wrote :
Revision history for this message
hermann meyer (brummer10) wrote :

This happen because you remove the viewport instead the button in your example code.
when you call
main_area.add(button_test);
you add a Gtk::Viewport to the scrolled window, the button is then a child of the viewport.
So after the call to
main_area.remove();
you remove the viewport and the button is still a child of the viewport.

Revision history for this message
Jonas Platte (jplatte) wrote :

Thanks! :)
I wondered why the remove function doesn't work, if it's just the function from Gtk::Bin and no additional function from the ScrolledWindow class. This is the solution!

Now that opens up a simple way to work around this, but I think this still is a misbehaviour and should be fixed. I already opened a thread in the gtkmm mailing list: https://mail.gnome.org/archives/gtkmm-list/2012-October/msg00002.html so I'll ask there again.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.