flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pio...@apache.org
Subject [24/50] [abbrv] git commit: [flex-asjs] [refs/heads/tlf] - LayoutBase Fix for strand set to null in remove bead, plus performance improvements in js
Date Sun, 18 Jun 2017 12:36:35 GMT
LayoutBase Fix for strand set to null in remove bead, plus performance improvements in js


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/08af60c7
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/08af60c7
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/08af60c7

Branch: refs/heads/tlf
Commit: 08af60c7755a9c7dd64ab62cbfff97443841bda7
Parents: b0f7013
Author: greg-dove <greg.dove@gmail.com>
Authored: Fri Jun 9 10:07:20 2017 +1200
Committer: greg-dove <greg.dove@gmail.com>
Committed: Fri Jun 9 10:17:54 2017 +1200

----------------------------------------------------------------------
 .../flex/org/apache/flex/core/LayoutBase.as     | 40 +++++++++++++++-----
 1 file changed, 30 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/08af60c7/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
index adadc75..be7d642 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
@@ -76,19 +76,39 @@ package org.apache.flex.core
          *  @productversion FlexJS 0.8
 		 * 
 		 * @flexjsignorecoercion org.apache.flex.core.ILayoutChild
+		 * @flexjsignorecoercion org.apache.flex.events.IEventDispatcher
          */
 		public function set strand(value:IStrand):void
 		{
-            host = value as ILayoutChild;
-			
-			IEventDispatcher(host).addEventListener("widthChanged", handleSizeChange);
-			IEventDispatcher(host).addEventListener("heightChanged", handleSizeChange);
-			IEventDispatcher(host).addEventListener("sizeChanged", handleSizeChange);
-			
-			IEventDispatcher(host).addEventListener("childrenAdded", handleChildrenAdded);
-			IEventDispatcher(host).addEventListener("initComplete", handleInitComplete);
-			
-			IEventDispatcher(host).addEventListener("layoutNeeded", handleLayoutNeeded);
+			var newHost:ILayoutChild = value as ILayoutChild;
+			var oldHost:ILayoutChild = host;
+			if (newHost != oldHost) {
+				var sizeChange:Function = handleSizeChange;
+                var childrenAdded:Function =handleChildrenAdded;
+				var initComplete:Function = handleInitComplete;
+				var layoutNeeded:Function = handleLayoutNeeded;
+                if (oldHost) {
+                    IEventDispatcher(oldHost).removeEventListener("widthChanged", sizeChange);
+                    IEventDispatcher(oldHost).removeEventListener("heightChanged", sizeChange);
+                    IEventDispatcher(oldHost).removeEventListener("sizeChanged", sizeChange);
+
+                    IEventDispatcher(oldHost).removeEventListener("childrenAdded", childrenAdded);
+                    IEventDispatcher(oldHost).removeEventListener("initComplete", initComplete);
+
+                    IEventDispatcher(oldHost).removeEventListener("layoutNeeded", layoutNeeded);
+                }
+				host = newHost;
+				if (newHost) {
+                    IEventDispatcher(newHost).addEventListener("widthChanged", sizeChange);
+                    IEventDispatcher(newHost).addEventListener("heightChanged", sizeChange);
+                    IEventDispatcher(newHost).addEventListener("sizeChanged", sizeChange);
+
+                    IEventDispatcher(newHost).addEventListener("childrenAdded", childrenAdded);
+                    IEventDispatcher(newHost).addEventListener("initComplete", initComplete);
+
+                    IEventDispatcher(newHost).addEventListener("layoutNeeded", layoutNeeded);
+				}
+			}
 		}
 		
 		/**


Mime
View raw message