| Author | Topic |
Posts: 307
Location: Cambridge UK
Registered: February 2005
|
|
Re: [jsbml-team] Clonging of SBML elements
|
16 Feb '12 04:58
|
 |
|
On 16/02/12 12:49, Andreas Dräger wrote:
> Dear all,
>
> Just now I am observing a strange behavior in graphical user
> interfaces when cloning SBML elements that have
> TreeNodeChangeListeners assigned to it. Currently, the class
> AbstractTreeNode assignes all registered TreeNodeChangeListeners to
> the clone (see clone constructor in AbstractTreeNode):
>
> if (node instanceof AbstractTreeNode) {
> this.listOfListeners.addAll(((AbstractTreeNode)
> node).listOfListeners);
> }
>
> When cloning an entire SBMLdocument, all of its components are deeply
> cloned. This causes that all TreeNodeChangeListeners are called again
> and again whilst cloning. Instead of notifying listeners about changes
> in the actual SBMLDocument to which the listeners are assigned, they
> do now observe change events from a different (new) SBMLDocument but
> all the values are actually not changing (because we are cloning).
>
> Therefore, I come to the conclusion that adding change listeners when
> cloning causes unexpected behavior. Furthermore, the only thing that
> is not deeply cloned here is the list of change listeners. We should
> either try to deep clone the change listeners as well (this would also
> avoid that the original listeners are called whilst cloning), or we
> should not add change listeners here at all.
>
> If you agree, I would like to uncomment this block or to try deep
> cloning of the listeners. Please let me know what you think. Should
> this change also be done in the 0.8 branch?
>
I would be for uncommenting the code and adapt the documentation,
javadoc and user guide to explain that when cloning, you should take
care of the listeners yourself.
I think it would be possible to use the same listeners for all the
objects (at least if they are in the same model) so we should not create
automatically many new objects when they are may be not needed.
Nico
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development
For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu
|
|
|