Browse Source

[prefab] Fix error when model path was a missing directory

Clément Espeute 1 month ago
parent
commit
6a8c71a11b
2 changed files with 28 additions and 24 deletions
  1. 12 8
      hide/comp/FileSelect.hx
  2. 16 16
      hide/comp/SceneEditor.hx

+ 12 - 8
hide/comp/FileSelect.hx

@@ -116,17 +116,21 @@ class FileSelect extends Component {
 		// We need to do this comparison since sys.FileSystem.exists() is case insensitive on Windows
 		var fullPath = ide.getPath(p);
 		var exists = false;
-		if (fullPath != null) {
-			var filename = fullPath.substr(fullPath.lastIndexOf('/') + 1);
-			var parentDir = fullPath.substring(0, fullPath.lastIndexOf('/'));
-			var files = sys.FileSystem.readDirectory(parentDir);
-			for (f in files) {
-				if (f == filename) {
-					exists = true;
-					break;
+		try {
+			if (fullPath != null) {
+				var filename = fullPath.substr(fullPath.lastIndexOf('/') + 1);
+				var parentDir = fullPath.substring(0, fullPath.lastIndexOf('/'));
+				var files = sys.FileSystem.readDirectory(parentDir);
+				for (f in files) {
+					if (f == filename) {
+						exists = true;
+						break;
+					}
 				}
 			}
+		} catch(e) {
 		}
+
 		var text = p == null ? "-- select --" : (exists ? "" : "[NOT FOUND] ") + p;
 		element.val(text);
 		element.attr("title", p == null ? "" : p);

+ 16 - 16
hide/comp/SceneEditor.hx

@@ -3651,7 +3651,7 @@ class SceneEditor {
 			return;
 		}
 
-		try {
+		// try {
 			if (others != null) {
 				for (prefab in others) {
 					var multiProps = new hide.comp.PropsEditor(null, null, new Element("<div>"));
@@ -3664,21 +3664,21 @@ class SceneEditor {
 				}
 			}
 			e.edit(edit);
-		} catch (e) {
-			if (others != null) {
-				// Multi edit non intrusive error
-				properties.clear();
-				var msg = e.toString();
-				msg = StringTools.replace(msg, '\n', '</br>');
-				var selection = [for (o in others) Type.getClassName(Type.getClass(o))].join(", ");
-				var stack = e.stack.toString();
-				stack = ~/\(chrome-extension:.*\)/g.replace(stack, "");
-				stack = StringTools.replace(stack, '\n', '</br>');
-				properties.add(new hide.Element('<p>Multi edit error</p><p>Selection : $selection</p><p>$msg</p><p>$stack</p>'));
-				return;
-			}
-			throw e;
-		}
+		// } catch (e) {
+		// 	if (others != null) {
+		// 		// Multi edit non intrusive error
+		// 		properties.clear();
+		// 		var msg = e.toString();
+		// 		msg = StringTools.replace(msg, '\n', '</br>');
+		// 		var selection = [for (o in others) Type.getClassName(Type.getClass(o))].join(", ");
+		// 		var stack = e.stack.toString();
+		// 		stack = ~/\(chrome-extension:.*\)/g.replace(stack, "");
+		// 		stack = StringTools.replace(stack, '\n', '</br>');
+		// 		properties.add(new hide.Element('<p>Multi edit error</p><p>Selection : $selection</p><p>$msg</p><p>$stack</p>'));
+		// 		return;
+		// 	}
+		// 	throw e;
+		// }