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



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-



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