ScrolledWindow doesn't properly remove widget from Viewport parent when calling ->remove()

Bug #30345 reported by Lakin Wecker
6
Affects Status Importance Assigned to Milestone
gtkmm2.4 (Ubuntu)
Incomplete
Medium
ubuntu-gnomemm

Bug Description

This is easily reproducible using the examples found at: http://www.gtkmm.org/docs/gtkmm-2.4/examples/book/scrolledwindow/

The following is a compile/running of the program with the error and a diff that shows how to reproduce the problem using this example program

lakin@zedd:~$ g++ *.cc `pkg-config --cflags --libs gtkmm-2.4`
lakin@zedd:~$ ./a.out

(a.out:26073): Gtk-CRITICAL **: gtk_scrolled_window_add_with_viewport: assertion `child->parent == NULL' failed
lakin@zedd:~$ diff examplewindow.cc.orig examplewindow.cc
46a47,48
> m_ScrolledWindow.remove();
> m_ScrolledWindow.add(m_Table);
lakin@zedd:~$

If you add the following code it works, but shouldn't this happen automatically when calling ->remove on a ScrolledWindow? I mean, I didn't explicitly ask for the widget to be added to the viewport, why should I remove it from the viewport when I need to remove the widget?

lakin@zedd:~$ g++ *.cc `pkg-config --cflags --libs gtkmm-2.4`
lakin@zedd:~$ ./a.out
lakin@zedd:~$ diff examplewindow.cc.orig examplewindow.cc
47a48,51
> dynamic_cast<Gtk::Viewport*>( m_ScrolledWindow.get_child() )->remove( );
> m_ScrolledWindow.remove();
> m_ScrolledWindow.add(m_Table);
>
lakin@zedd:~$

Changed in gtkmm2.4:
assignee: nobody → dholbach
Revision history for this message
Daniel Holbach (dholbach) wrote :

Thanks for your bug report. Which version of gtkmm2.4 do you use? I can't reproduce the bug. It seems to work nicely for me.

Changed in gtkmm2.4:
status: Unconfirmed → Needs Info
Revision history for this message
Daniel Holbach (dholbach) wrote :

Sorry, just realized you changed the example code. Why do you try to add something to m_ScrolledWindow after you removed it?

Revision history for this message
Lakin Wecker (lakin) wrote :

I'm working on a project that has three different views on the data I'm presenting. 2 use pictures at different levels of resolution and for those, I use widgets which inherit from DrawingArea. The third uses OpenGL to render the terrain, and for this I use a widget which inherits from Gtk::GL::DrawingArea which is provided by gtkglextmm.

In any case, when the users switches between the views I switch the objects that are used, and because ScrolledWindow is a container I figured it should obvious that I could add and remove widgets from it when I needed to switch the views. That's when I ran into this problem.

Changed in gtkmm2.4:
assignee: dholbach → ubuntu-gnomemm
Revision history for this message
Murray Cumming (murrayc) wrote :

I still don't see what version of gtkmm is being used.

Revision history for this message
Murray Cumming (murrayc) wrote :

Lakin, please respond so we can help you.

Revision history for this message
Lakin Wecker (lakin) wrote :

Wow, I totally missed the question of what verion was being used both time around. :( Sorry about that.

I don't remember exactly which version I was using then but it was very likely the stock ubuntu devel version. In fact I was able to reproduce the same issue with libgtkmm-2.4-dev in Ubuntu 7.10. Hopefully the following paste will illustrate both the issue and the version I have.

lakin@zedd:~$ diff examplewindow.cc.orig examplewindow.cc
46a47,49
> //dynamic_cast<Gtk::Viewport*>( m_ScrolledWindow.get_child() )->remove( );
> m_ScrolledWindow.remove();
> m_ScrolledWindow.add(m_Table);
lakin@zedd:~$ g++ *.cc `pkg-config --cflags --libs gtkmm-2.4`
lakin@zedd:~$ ./a.out

(a.out:8303): Gtk-CRITICAL **: gtk_scrolled_window_add_with_viewport: assertion `child->parent == NULL' failed
lakin@zedd:~$ diff examplewindow.cc.orig examplewindow.cc
46a47,49
> dynamic_cast<Gtk::Viewport*>( m_ScrolledWindow.get_child() )->remove( );
> m_ScrolledWindow.remove();
> m_ScrolledWindow.add(m_Table);
lakin@zedd:~$ g++ *.cc `pkg-config --cflags --libs gtkmm-2.4`
lakin@zedd:~$ ./a.out
lakin@zedd:~$ apt-cache showpkg libgtkmm-2.4-dev
Package: libgtkmm-2.4-dev
Versions:
1:2.12.0-0ubuntu1 (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_gutsy_main_binary-i386_Packages) (/var/lib/dpkg/status)
 Description Language:
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_gutsy_main_binary-i386_Packages
                  MD5: 6d5830214c564ddb8057f72c66ec2d2e

Reverse Depends:
  libview-dev,libgtkmm-2.4-dev
  libsexymm-dev,libgtkmm-2.4-dev
  libgtksourceviewmm-2.0-dev,libgtkmm-2.4-dev 2.4
  libgtksourceviewmm-1.0-dev,libgtkmm-2.4-dev 2.4
  libglom-dev,libgtkmm-2.4-dev 2.6.1
  libbakery-2.4-dev,libgtkmm-2.4-dev 1:2.8.0
  libbakery-2.3-dev,libgtkmm-2.4-dev 2.6.2-0ubuntu2
  glademm,libgtkmm-2.4-dev
  bmpx-dev,libgtkmm-2.4-dev
  libgtkmm-2.4-doc,libgtkmm-2.4-dev
  libgnomemm-2.6-dev,libgtkmm-2.4-dev 2.8.0
  libgnomecanvasmm-2.6-dev,libgtkmm-2.4-dev 1:2.6.5-1
  libglibmm-2.4-dev,libgtkmm-2.4-dev
  libglademm-2.4-dev,libgtkmm-2.4-dev 1:2.6.5-1
  libgconfmm-2.6-dev,libgtkmm-2.4-dev 1:2.6.5-1
Dependencies:
1:2.12.0-0ubuntu1 - libgtkmm-2.4-1c2a (5 1:2.12.0-0ubuntu1) libgtk2.0-dev (2 2.12.0) libglibmm-2.4-dev (2 2.14.0) libatk1.0-dev (4 1.9.0) libcairomm-1.0-dev (2 1.1.12)
Provides:
1:2.12.0-0ubuntu1 -
Reverse Provides:
lakin@zedd:~$

Revision history for this message
rusivi2 (rusivi2-deactivatedaccount) wrote :

Thank you for posting this bug.

Ubuntu 7.10 is in End of Life status and this package has been updated. Please update and repost detailed error report.

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.