This is an automated email from the ASF dual-hosted git repository. gregdove pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit f95c6761e8701d3886e15606b8fa9aef52a9c6b6 Author: greg-dove <[email protected]> AuthorDate: Tue May 17 14:24:53 2022 +1200 Revert "Avoid the possibility of infinite loops (in JS only, SWF untested) with xml watchers. This can happen if changes are made in watcher functions." This reverts commit acab343f73b939bb3b28a13f9142cba4f799104a. --- .../src/main/royale/mx/utils/XMLNotifier.as | 71 ++++------------------ 1 file changed, 12 insertions(+), 59 deletions(-) diff --git a/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as b/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as index c4d033b476..5bc8a13fa1 100644 --- a/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as +++ b/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as @@ -20,14 +20,10 @@ package mx.utils { -//import org.apache.royale.utils.ObjectMap; +import org.apache.royale.utils.ObjectMap; import mx.core.mx_internal; import mx.utils.IXMLNotifiable; -COMPILE::SWF{ - import flash.utils.Dictionary; -} - use namespace mx_internal; /** @@ -102,32 +98,13 @@ public class XMLNotifier { callee = notificationFunction; } - //var xmlWatchers:ObjectMap = callee["watched"]; - - COMPILE::SWF{ - var xmlWatchers:Dictionary = callee["watched"]; - for (var notifiable:Object in xmlWatchers) { + var xmlWatchers:ObjectMap = callee["watched"]; + if (xmlWatchers != null) + { + xmlWatchers.forEach( function(truevalue:Object,notifiable:Object,map:Object):void { IXMLNotifiable(notifiable).xmlNotification(currentTarget, ty, tar, value, detail); - } + } ); } - - COMPILE::JS{ - var xmlWatchers:Map = callee["watched"]; - if (xmlWatchers != null) - { - var collected:Array = []; - //note, if we don't collect these first and try to iterate directly, then there can be the case that iterating is infinite if the function caLL also somehow affects the xmlWatchers Map: - xmlWatchers.forEach( function(truevalue:Object,notifiable:Object,map:Object):void { - collected.push(notifiable); - } ); - - while(collected.length){ - IXMLNotifiable(collected.shift()).xmlNotification(currentTarget, ty, tar, value, detail); - } - } - } - - } return notificationFunction; @@ -204,25 +181,13 @@ public class XMLNotifier } // Watch lists are maintained on the notification function. - if (watcherFunction["watched"] == undefined) { - // watcherFunction["watched"] = xmlWatchers = new ObjectMap(true,true); - COMPILE::SWF{ - var xmlWatchers:Dictionary = watcherFunction["watched"] = new Dictionary(); - } - - COMPILE::JS{ - var xmlWatchers:Map= watcherFunction["watched"] = new Map(); - } - } + var xmlWatchers:ObjectMap; + if (watcherFunction["watched"] == undefined) + watcherFunction["watched"] = xmlWatchers = new ObjectMap(true,true); else xmlWatchers = watcherFunction["watched"]; - COMPILE::SWF{ - xmlWatchers[notifiable]=true; - } - COMPILE::JS{ - xmlWatchers.set(notifiable, true); - } + xmlWatchers.set(notifiable, true); } } @@ -258,24 +223,12 @@ public class XMLNotifier if (!(watcherFunction is Function)) return; - COMPILE::SWF{ - var xmlWatchers:Dictionary; - } - - COMPILE::JS{ - var xmlWatchers:Map; - } + var xmlWatchers:ObjectMap; if (watcherFunction["watched"] != undefined) { xmlWatchers = watcherFunction["watched"]; - COMPILE::SWF{ - delete xmlWatchers[notifiable]; - } - COMPILE::JS{ - xmlWatchers.delete(notifiable); - } - + xmlWatchers.delete(notifiable); } } }
