Storing data in a TreeIter (custom TreeModel)



Hi again,

I'm not too worried about this problem, because I've found a workaround
for this project, but I would like to know how to do it "the right way." 
The problem is this: I'm having some trouble actually storing data in a
TreeIter :o)
                                                                          
                                                                         
                                                                         
                        
I can't figure out how to store data in the last two user_data fields.  My
database is structured so that each row stores its own id, the id of its
sibling (the row that should come immediately after it when viewed, or
65535 when there is no such row), and the id of its parent.  I'd like to
use the extra two fields of the TreeIter to store the sibling and parent
values.
                                                                          
                                                 
I know the user_data fields are supposed to be references, so I tried
using something like:
                                                                          
                                                 
return [$self->{_stamp}, ($id+1)-1, \$sibling, \$parent];
                                                                          
                                                 
from GET_ITER.  The plus-one-minus-one thing seems to be necessary to get
$id, which came from the DB through DBI, into the TreeIter, which wants
an integer for the second field.  For some reason, XS's SvIOK wouldn't
return true unless I did that.  This seems to work well.

When I try to get the last two values back out of the TreeIter later, I
get an error on dereferencing.  Unfortunately, I don't remember exactly
what the error was, because I changed the model so it doesn't work like
that anymore :o)  Now, I'm just storing the id in the iter, passing undef
for the other two fields, then querying the DB whenever I need the
sibling or parent info for a particular id.  That works very well.

If it would be helpful to have the exact error, I'll change the model
back, but it would take some time :o)

Thanks for your help!

Zach

-- 
And I say, Give me back my memory, or I'll rip you into three boy scouts
and a watchband!
                                           ---Aaron in "Remind Me Again"
------------------------------------------------------------------------
Zach Bean, zb forty2 com, web forty2 com          http://www.forty2.com

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



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