Re: Custom TreeModel

On Sun, Jan 17, 2010 at 11:03 PM, Emmanuel Rodriguez <emmanuel rodriguez gmail com> wrote:

On Sun, Jan 17, 2010 at 5:44 PM, Aristotle Pagaltzis <pagaltzis gmx de> wrote:
* Emmanuel Rodriguez <emmanuel rodriguez gmail com> [2010-01-14 08:35]:
> I could rewrite this tree model with a pure Perl tree model
> (HTML::Tree) and add it to the Gtk2-Perl examples.

It sounds to me like what you want is to store some kind of
pointer in the iter (eg. an XPath) whereby the same node can be
re-requested from XML::LibXML in the event that it has to.
I did implement this stragey too but the XPath string was being lost once inserted into the TreeIter. Dumping the TreeIter received and returned by all methodsÂshows that the incoming iters lose the value returned by the previous method.

I'm guessing that the problem occurs becauseÂthere's no other variable that holds a reference to the values stored in TreeIter. Once the method that builds the TreeIter returns the Perl scalars stored in the iter get reclaimed.

This is why I tend to believe that with a pure Perl tree things will work better as the nodes will still have a refcount of 1. Hopefully this week I will have the time to test this.
I managed to find the time to implement a Gtk2::TreeModel that's backed by a pure Perl tree [1]. Things work as expected and as long as the tree nodes are in the main Perl structure there's no problem with the TreeIters.

Emmanuel Rodriguez

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