Re: Custom TreeModel

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 see that there's not way to avoid the cache. It's a bit of
> a pity that I can't detect when an iter is no longer needed as
> eventually all nodes will be duplicated into the cache.
> I'm guessing that with a normal (pure Perl) tree model this
> will not be the case as nodes will be already in the model.
> Using XML::LibXML nodes is a bit peculiar as the memory
> management is a bit different. If I'm not mistaken XML::LibXML
> assumes that nodes are attached to the underlying C model and
> that the SVs wrapping them can be easily discarded at anytime
> as long as the original C structure lives.
> 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.
Emmanuel Rodriguez

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