Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve AssetLibrary.loadText, include additional error information i…
…f asset does not load
- Loading branch information
Showing
1 changed file
with
28 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import lime.app.Future; | |
import lime.app.Promise; | ||
import lime.media.AudioBuffer; | ||
import lime.graphics.Image; | ||
import lime.net.HTTPRequest; | ||
import lime.text.Font; | ||
import lime.utils.AssetType; | ||
|
||
|
@@ -635,27 +636,26 @@ class AssetLibrary { | |
|
||
return Future.withValue (cachedText.get (id)); | ||
|
||
} else { | ||
} else if (cachedBytes.exists (id) || classTypes.exists (id)) { | ||
|
||
var bytes = getBytes (id); | ||
|
||
return loadBytes (id).then (function (bytes) { | ||
if (bytes == null) { | ||
|
||
return new Future<String> (function () { | ||
|
||
if (bytes == null) { | ||
|
||
return null; | ||
|
||
} else { | ||
|
||
var text = bytes.getString (0, bytes.length); | ||
cachedText.set(id, text); | ||
return text; | ||
|
||
} | ||
|
||
}, true); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
return cast Future.withValue (null); | ||
|
||
} else { | ||
|
||
}); | ||
var text = bytes.getString (0, bytes.length); | ||
cachedText.set (id, text); | ||
return Future.withValue (text); | ||
|
||
} | ||
|
||
} else { | ||
|
||
var request = new HTTPRequest<String> (); | ||
return request.load (paths.get (id)); | ||
This comment has been minimized.
Sorry, something went wrong.
vizanto
Contributor
|
||
|
||
} | ||
|
||
|
@@ -859,7 +859,16 @@ class AssetLibrary { | |
|
||
private function load_onError (id:String, message:Dynamic):Void { | ||
|
||
promise.error ("Error loading asset \"" + id + "\""); | ||
if (message != null && message != "") { | ||
|
||
promise.error ("Error loading asset \"" + id + "\": " + Std.string (message)); | ||
|
||
} else { | ||
|
||
promise.error ("Error loading asset \"" + id + "\""); | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
Depends how you look at it:
Before this patch,
Assets.loadText
would not use the cache but callAssetLibrary.loadText
which cached it anyway.Now,
cachedText
is not updated anywhere, except forthis.load
throughloadText_onComplete
.Should caching of
TEXT
andBINARY
be added tolime.utils.Assets.loadText
?