Permalink
Browse files

Fixed bug where LinkableVariable default value triggers were causing

slow startup.
Moved DebugTimer to core project.
  • Loading branch information...
1 parent d13aee2 commit 971cc5b17d07e0b26a690d080037f6f0198ba29c @adufilie adufilie committed Feb 17, 2012
@@ -21,6 +21,7 @@ package weave.core
{
import mx.utils.ObjectUtil;
+ import weave.api.WeaveAPI;
import weave.api.core.ILinkableVariable;
import weave.api.reportError;
@@ -64,10 +65,7 @@ package weave.core
// If callbacks were triggered, make sure callbacks are triggered again one frame later when
// it is possible for other classes to have a pointer to this object and retrieve the value.
if (defaultValueTriggersCallbacks && triggerCounter > DEFAULT_TRIGGER_COUNT)
- {
- addImmediateCallback(null, removeCallback, [_defaultValueTrigger]);
- addGroupedCallback(null, _defaultValueTrigger, true);
- }
+ WeaveAPI.StageUtils.callLater(this, _defaultValueTrigger, null, false);
}
}
@@ -76,9 +74,6 @@ package weave.core
*/
private function _defaultValueTrigger():void
{
- // only do this once
- removeCallback(_defaultValueTrigger);
-
// unless callbacks were triggered again since the default value was set, trigger callbacks now
if (!wasDisposed && triggerCounter == DEFAULT_TRIGGER_COUNT + 1)
triggerCallbacks();
@@ -36,6 +36,7 @@ package weave.core
import weave.api.core.ICallbackCollection;
import weave.api.core.IStageUtils;
import weave.api.reportError;
+ import weave.utils.DebugTimer;
use namespace mx_internal;
@@ -149,10 +150,11 @@ package weave.core
* This function gets called on ENTER_FRAME events.
*/
private function handleEnterFrame():void
- {
+ {
var currentTime:int = getTimer();
_previousFrameElapsedTime = currentTime - _currentFrameStartTime;
- _currentFrameStartTime = currentTime;
+ _currentFrameStartTime = currentTime;
+
// update mouse coordinates
_lastMousePoint.x = _stage.mouseX;
_lastMousePoint.y = _stage.mouseY;
@@ -166,19 +168,19 @@ package weave.core
if (_callNextFrameArray.length > 0)
{
calls = _callNextFrameArray;
- _callNextFrameArray = [];
+ _callNextFrameArray = [];
for (i = 0; i < calls.length; i++)
{
// args: (relevantContext:Object, method:Function, parameters:Array = null, allowMultipleFrameDelay:Boolean = true)
args = calls[i] as Array;
stackTrace = _stackTraceMap[args];
// don't call the function if the relevantContext was disposed of.
if (!WeaveAPI.SessionManager.objectWasDisposed(args[0]))
- (args[1] as Function).apply(null, args[2]);
- }
+ (args[1] as Function).apply(null, args[2]);
+ }
}
-
- if (_callLaterArray.length > 0 && UIComponentGlobals.callLaterSuspendCount <= 0)
+
+ if (_callLaterArray.length > 0 && UIComponentGlobals.callLaterSuspendCount <= 0)
{
//trace("handle ENTER_FRAME, " + _callLaterArray.length + " callLater functions, " + currentFrameElapsedTime + " ms elapsed this frame");
// Make a copy of the function calls and clear the private array before executing any functions.
@@ -202,10 +204,10 @@ package weave.core
args = calls[i] as Array;
stackTrace = _stackTraceMap[args]; // check this for debugging where the call came from
// don't call the function if the relevantContext was disposed of.
- if (!WeaveAPI.SessionManager.objectWasDisposed(args[0]))
- (args[1] as Function).apply(null, args[2]);
+ if (!WeaveAPI.SessionManager.objectWasDisposed(args[0]))
+ (args[1] as Function).apply(null, args[2]);
}
- }
+ }
}
private var _currentFrameStartTime:int = getTimer(); // this is the result of getTimer() on the last ENTER_FRAME event.
private var _previousFrameElapsedTime:int = 0; // this is the amount of time it took to process the previous frame.
@@ -21,11 +21,9 @@ package weave.radviz
{
import flash.utils.Dictionary;
- import weave.api.data.IAttributeColumn;
import weave.api.radviz.ILayoutAlgorithm;
import weave.core.CallbackCollection;
- import weave.core.LinkableHashMap;
- import weave.utils.DebugTimer;
+ import weave.utils.DebugTimer;
/**
* An abstract class with a callback collection which implements ILayoutAlgorithm

0 comments on commit 971cc5b

Please sign in to comment.