Handle null in more from* methods

This commit is contained in:
Joshua Granick
2016-08-03 13:10:39 -07:00
parent 4b08e24f7d
commit 060f7002ff
3 changed files with 13 additions and 4 deletions

View File

@@ -58,20 +58,22 @@ class AudioBuffer {
#end
}
#if lime_console
@:void
private static function finalize (a:AudioBuffer):Void {
a.dispose ();
}
#end
public static function fromBytes (bytes:Bytes):AudioBuffer {
if (bytes == null) return null;
#if lime_console
lime.Lib.notImplemented ("AudioBuffer.fromBytes");
@@ -100,6 +102,8 @@ class AudioBuffer {
public static function fromFile (path:String):AudioBuffer {
if (path == null) return null;
#if lime_console
var mode = StringTools.endsWith(path, ".wav") ? FMODMode.LOOP_OFF : FMODMode.LOOP_NORMAL;

View File

@@ -513,6 +513,7 @@ class Image {
public static function fromFile (path:String, onload:Image -> Void = null, onerror:Void -> Void = null):Image {
if (image == null) return null;
var image = new Image ();
image.__fromFile (path, onload, onerror);
return image;

View File

@@ -83,6 +83,8 @@ class Font {
public static function fromBytes (bytes:Bytes):Font {
if (bytes == null) return null;
var font = new Font ();
font.__fromBytes (bytes);
@@ -97,6 +99,8 @@ class Font {
public static function fromFile (path:String):Font {
if (path == null) return null;
var font = new Font ();
font.__fromFile (path);