[ https://issues.apache.org/jira/browse/FLEX-27837?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Justin Mclean updated FLEX-27837: --------------------------------- Labels: easyfix (was: ) > ChangeWatcher bug > ----------------- > > Key: FLEX-27837 > URL: https://issues.apache.org/jira/browse/FLEX-27837 > Project: Apache Flex > Issue Type: Bug > Components: .Unspecified - Framework > Affects Versions: Adobe Flex SDK Previous > Environment: Affected OS(s): Windows > Affected OS(s): Windows XP > Language Found: English > Reporter: Adobe JIRA > Labels: easyfix > > When I used this class BindingUtils to binding work, I called this method: > public static function bindSetter(setter:Function, host:Object, > chain:Object, > commitOnly:Boolean = false, > useWeakReference:Boolean = > false):ChangeWatcher > I found there is a wrong description about the "useWeakReference", below is > the signature of useWeakReference in the API Document: > useWeakReference : Boolean > (default = false) Determines whether the reference to the host is strong or > weak. > but I don't think it determines the host, but the ChangeWatcher instance > itself, it determines whether the reference to the ChangeWatcher instance is > strong or weak. > So,I test the ChangeWatcher instance is real be gced. If the chain's length > is only 1,the useWeakReference works, the ChangeWatcher instance will be > gced,but if the chain's length is more than 1,the useWeakReference doesn't > work. > the source code: > BindingUtils : > public static function bindSetter(setter:Function, host:Object, > chain:Object, > commitOnly:Boolean = false, > useWeakReference:Boolean = > false):ChangeWatcher > { > var w:ChangeWatcher = > ChangeWatcher.watch(host, chain, null, commitOnly, > useWeakReference); > > if (w != null) > { > var invoke:Function = function(event:*):void > { > setter(w.getValue()); > }; > w.setHandler(invoke); > invoke(null); > } > > return w; > } > ChangeWatcher : > public static function watch(host:Object, chain:Object, > handler:Function, > commitOnly:Boolean = false, > useWeakReference:Boolean = > false):ChangeWatcher > { > if (!(chain is Array)) > chain = [ chain ]; > if (chain.length > 0) > { > var w:ChangeWatcher = > new ChangeWatcher(chain[0], handler, commitOnly, > watch(null, chain.slice(1), handler, commitOnly)); > //there is the reason!the default arg is false,so the 1st ChangeWatcher is > "useWeakReference = true",but others are "ChangeWatcher = false" > w.useWeakReference = useWeakReference; > w.reset(host); > return w; > } > else > { > return null; > } > } > I think the right code must be "watch(null, chain.slice(1), handler, > commitOnly, useWeakReference)); " > the chain of ChangeWatchers will not be gced. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira