[Java-gnome-developer] Re: A CustomTreeModel [was: JTable(Swing) to java-gnome]
Brought to you by:
afcowie
From: Ka-Hing C. <ka...@gm...> - 2005-04-07 01:51:05
|
On Apr 6, 2005 11:07 AM, Joao Victor <jvi...@ya...> wrote: > Hmm, ok... well, just consider this situation (i don't know if it's possible, that's what i would > like to know): > > - A CustomTreeModel is constructed and filled with Java objects > - The C-side creates the Iters, which point to the Java objects in the model > - Some Java object is GC'ed, because no one in the Java-side is using it anymore > - The C-side has a reference to an object that doesn't exist anymore > - The C-side tries to use that reference, and boom. You have a point, this can happen if someone creates a new object in getChild and return it without storing it. I am not sure if this is very common but definitely should be legal. So local ref and weak ref are out. If global ref is used they we have to free them in the destructor of TreeIter, which of course is only possible if TreeIter is aware of CustomTreeModel, which essentially means if CustomTreeModel is accepted as part of java-gtk. As the person who started all this, I would say that it's definitely a good idea (I would even suggest to drop the word "Custom", make this the base class of all TreeModels, and move the getValue/setValue stuff to a DefaultTreeModel (like how swing does it)). Of course, I may not be the most unbiased person :-) What do others think? -khc |