From 68371c5ff5ddb8b6685b1ec5bbf07474b1a7eb72 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 29 Feb 2016 15:06:17 +0800 Subject: [PATCH] Use invokeAndRemove instead of invoke and removeAll --- cocos2d/core/load-pipeline/pipeline.js | 5 +---- cocos2d/core/platform/callbacks-invoker.js | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/load-pipeline/pipeline.js b/cocos2d/core/load-pipeline/pipeline.js index 83b6e7b21c..1956567e21 100644 --- a/cocos2d/core/load-pipeline/pipeline.js +++ b/cocos2d/core/load-pipeline/pipeline.js @@ -390,10 +390,7 @@ JS.mixin(Pipeline.prototype, { this.complete(); - items.invoke(url, item); - - // remove all callbacks added for url - items.removeAll(url); + items.invokeAndRemove(url, item); }, /** diff --git a/cocos2d/core/platform/callbacks-invoker.js b/cocos2d/core/platform/callbacks-invoker.js index 263f35d673..ac387ae8c9 100644 --- a/cocos2d/core/platform/callbacks-invoker.js +++ b/cocos2d/core/platform/callbacks-invoker.js @@ -219,6 +219,7 @@ CallbacksInvoker.prototype.invoke = function (key, p1, p2, p3, p4, p5) { * @param {any} [p5] */ CallbacksInvoker.prototype.invokeAndRemove = function (key, p1, p2, p3, p4, p5) { + this._invoking = key; // this.invoke(key, p1, p2, p3, p4, p5); // 这里不直接调用invoke仅仅是为了减少调用堆栈的深度,方便调试 var list = this._callbackTable[key], i, l, target; @@ -235,6 +236,8 @@ CallbacksInvoker.prototype.invokeAndRemove = function (key, p1, p2, p3, p4, p5) } } } + this._invoking = null; + this._toRemove.length = 0; this.removeAll(key); };