Browse Source

[image] prevent loadTexture from registering watch more than once

Clément Espeute 1 tuần trước cách đây
mục cha
commit
c129ca8d4c
1 tập tin đã thay đổi với 7 bổ sung2 xóa
  1. 7 2
      hxd/res/Image.hx

+ 7 - 2
hxd/res/Image.hx

@@ -72,6 +72,7 @@ class Image extends Resource {
 	public static var MIPMAP_MAX_SIZE = 0;
 
 	static var ENABLE_AUTO_WATCH = true;
+	var watchRegistered = false;
 
 	var tex:h3d.mat.Texture;
 	var inf:ImageInfo;
@@ -558,8 +559,10 @@ class Image extends Resource {
 						f();
 				}
 
-				if (ENABLE_AUTO_WATCH)
+				if (ENABLE_AUTO_WATCH && !watchRegistered) {
+					watchRegistered = true;
 					watch(watchCallb);
+				}
 			});
 			return;
 		}
@@ -626,8 +629,10 @@ class Image extends Resource {
 					+ " " + entry.path);
 			}
 			tex.realloc = () -> loadTexture();
-			if (ENABLE_AUTO_WATCH)
+			if (ENABLE_AUTO_WATCH && !watchRegistered) {
+				watchRegistered = true;
 				watch(watchCallb);
+			}
 		}
 		if (entry.isAvailable)
 			load();