Fix use of Assets.load* with the same ID and different callbacks
This commit is contained in:
@@ -40,7 +40,6 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
public var type (default, null) = new Map <String, AssetType> ();
|
public var type (default, null) = new Map <String, AssetType> ();
|
||||||
|
|
||||||
private var lastModified:Float;
|
private var lastModified:Float;
|
||||||
private var loadHandlers:Map<String, Dynamic>;
|
|
||||||
private var threadPool:ThreadPool;
|
private var threadPool:ThreadPool;
|
||||||
private var timer:Timer;
|
private var timer:Timer;
|
||||||
|
|
||||||
@@ -137,15 +136,15 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
private function createThreadPool ():Void {
|
private function createThreadPool ():Void {
|
||||||
|
|
||||||
threadPool = new ThreadPool (0, 2);
|
threadPool = new ThreadPool (0, 2);
|
||||||
threadPool.doWork.add (function (id, getMethod) {
|
threadPool.doWork.add (function (id, data) {
|
||||||
|
|
||||||
threadPool.sendComplete (id, getMethod (id));
|
data.result = data.getMethod (id);
|
||||||
|
threadPool.sendComplete (data.handler, data);
|
||||||
|
|
||||||
});
|
});
|
||||||
threadPool.onComplete.add (function (id, data) {
|
threadPool.onComplete.add (function (id, data) {
|
||||||
|
|
||||||
var handler = loadHandlers.get (id);
|
data.handler (data.result);
|
||||||
handler (data);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -570,13 +569,11 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
|
|
||||||
if (threadPool == null) {
|
if (threadPool == null) {
|
||||||
|
|
||||||
loadHandlers = new Map ();
|
|
||||||
createThreadPool ();
|
createThreadPool ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadHandlers.set (id, handler);
|
threadPool.queue (id, { handler: handler, getMethod: getBytes });
|
||||||
threadPool.queue (id, getBytes);
|
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@@ -626,13 +623,11 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
|
|
||||||
if (threadPool == null) {
|
if (threadPool == null) {
|
||||||
|
|
||||||
loadHandlers = new Map ();
|
|
||||||
createThreadPool ();
|
createThreadPool ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadHandlers.set (id, handler);
|
threadPool.queue (id, { handler: handler, getMethod: getImage });
|
||||||
threadPool.queue (id, getImage);
|
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user