#publish try fix mem leak

main
xian18 3 years ago
parent c98c76c1f0
commit 3e4e940c78

@ -420,11 +420,13 @@ var SF_Plugins = SF_Plugins || {};
this._nextJob = "";
}).bind(this);
var callBacks = CallBack.registerOneTimeList([success, fail]);
UpdateUtils.downloadRelativeUrl(
SF_AutoUpdate.remoteFileInfoName,
SF_AutoUpdate.remoteFileInfoName,
CallBack.registerOneTime(success),
CallBack.registerOneTime(fail)
callBacks[0],
callBacks[1]
);
}
@ -495,11 +497,13 @@ var SF_Plugins = SF_Plugins || {};
FileUtils.mkdirs(FileUtils.getParent(file.file_name));
}
var callBacks = CallBack.registerOneTimeList([success, fail]);
UpdateUtils.downloadRelativeUrl(
file.file_name,
file.file_name,
CallBack.registerOneTime(success),
CallBack.registerOneTime(fail)
callBacks[0],
callBacks[1]
);
}
//=============================================================================

@ -428,4 +428,27 @@ var SF_Plugins = SF_Plugins || {};
return this.convertToString(closureIndex);
}
CallBack.registerOneTimeList = function (closureFunctionList) {
var indexList = [];
var result = [];
for (var i = 0; i < closureFunctionList.length; i++) {
var index = this.getNew();
indexList.push(index);
}
var removeAllFunc = (function () {
for (var i = 0; i < indexList.length; i++) {
this.unregister(indexList[i]);
}
});
for (var i = 0; i < indexList.length; i++) {
this.setByClosureIndex(indexList[i], (function () { closureFunctionList[i](); removeAllFunc(); }).bind(this));
result.push(this.convertToString(indexList[i]));
}
return result;
}
})();
Loading…
Cancel
Save