Re: [gtkmm] Gtk::ScrolledWindow add/remove problem



Thanks for your answer.
I finaly used a Gtk::notebook, and it works well.
By the way I noticed that there is a Gtk::Widget::reparent method, allowing to move a widget from a container to another, avoiding the deletion of the widget. Maybe this is the solution.
Thanks
Ben

Benoît Touron wrote:

 > Hello again,
 >
> I am writing an app using a pane window. In the left side, there is a > tree and in the right part a Gtk::ScrolledWindow. > When the tree selection changes, I need to change the widget contained > in the ScrolledWindow.
 > To do this, I use m_scroll.remove(), and then m_scoll.add(newwidget).
 > It works a couple of times (usually 3), then it crashes (access
 > violation), in the add mathod.


Well, I'm not an expert, but I have had the exact same problem, and worked around it... My guess is that when you create the ScrolledWindow with Gtk::manage(new ...), you make sort of a garbage collection thingy for it. Then when you do m_scroll.remove(), the garbage collection deletes it from memory. This means that when you switch once, and then switch back, the program crashes because you try to insert a deleted object.

Whether I'm right or wrong here, I worked around it by simply removing the Gtk::manage() around the creation of the ScrolledWindow instances.

-Tor Arvid-
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]