diff options
author | portix <portix@gmx.net> | 2012-12-08 02:08:17 +0100 |
---|---|---|
committer | portix <portix@gmx.net> | 2012-12-08 02:08:17 +0100 |
commit | 89e9043503133bc4a89cc169bf328bc6732eb330 (patch) | |
tree | 3d119eec15a4695e3e039c0500aeb3e3efaae41e /src | |
parent | e546c944645580065fd7b8df7f2e048f11d26311 (diff) | |
download | dwb-89e9043503133bc4a89cc169bf328bc6732eb330.zip |
Destroy current deferred before chaining further
Diffstat (limited to 'src')
-rw-r--r-- | src/scripts.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/scripts.c b/src/scripts.c index 4da0aed1..d2db539e 100644 --- a/src/scripts.c +++ b/src/scripts.c @@ -1443,19 +1443,20 @@ deferred_resolve(JSContextRef ctx, JSObjectRef f, JSObjectRef this, size_t argc, if (priv->resolve) ret = JSObjectCallAsFunction(ctx, priv->resolve, NULL, argc, argv, exc); - if (priv->next) + JSObjectRef next = priv->next; + deferred_destroy(ctx, this, priv); + + if (next) { if ( ret && JSValueIsObjectOfClass(ctx, ret, s_deferred_class) ) { JSObjectRef o = JSValueToObject(ctx, ret, NULL); - deferred_transition(ctx, priv->next, o)->reject = NULL; - priv->next = o; + deferred_transition(ctx, next, o)->reject = NULL; } else - deferred_resolve(ctx, f, priv->next, argc, argv, exc); + deferred_resolve(ctx, f, next, argc, argv, exc); } - deferred_destroy(ctx, this, priv); return UNDEFINED; } @@ -1471,18 +1472,19 @@ deferred_reject(JSContextRef ctx, JSObjectRef f, JSObjectRef this, size_t argc, if (priv->reject) ret = JSObjectCallAsFunction(ctx, priv->reject, NULL, argc, argv, exc); - if (priv->next) + JSObjectRef next = priv->next; + deferred_destroy(ctx, this, priv); + + if (next) { if ( ret && JSValueIsObjectOfClass(ctx, ret, s_deferred_class) ) { JSObjectRef o = JSValueToObject(ctx, ret, NULL); - deferred_transition(ctx, priv->next, o)->resolve = NULL; - priv->next = o; + deferred_transition(ctx, next, o)->resolve = NULL; } else - deferred_reject(ctx, f, priv->next, argc, argv, exc); + deferred_reject(ctx, f, next, argc, argv, exc); } - deferred_destroy(ctx, this, priv); return UNDEFINED; } |