Kaynağa Gözat

Merge pull request #103944 from KoBeWi/more_red_info

Improve error messages for `add_property_info()`
Thaddeus Crews 3 ay önce
ebeveyn
işleme
16aaa0a213

+ 6 - 2
core/config/project_settings.cpp

@@ -1221,8 +1221,12 @@ Variant _GLOBAL_DEF(const PropertyInfo &p_info, const Variant &p_default, bool p
 }
 }
 
 
 void ProjectSettings::_add_property_info_bind(const Dictionary &p_info) {
 void ProjectSettings::_add_property_info_bind(const Dictionary &p_info) {
-	ERR_FAIL_COND(!p_info.has("name"));
-	ERR_FAIL_COND(!p_info.has("type"));
+	ERR_FAIL_COND_MSG(!p_info.has("name"), "Property info is missing \"name\" field.");
+	ERR_FAIL_COND_MSG(!p_info.has("type"), "Property info is missing \"type\" field.");
+
+	if (p_info.has("usage")) {
+		WARN_PRINT("\"usage\" is not supported in add_property_info().");
+	}
 
 
 	PropertyInfo pinfo;
 	PropertyInfo pinfo;
 	pinfo.name = p_info["name"];
 	pinfo.name = p_info["name"];

+ 1 - 0
doc/classes/ProjectSettings.xml

@@ -51,6 +51,7 @@
 				ProjectSettings.AddPropertyInfo(propertyInfo);
 				ProjectSettings.AddPropertyInfo(propertyInfo);
 				[/csharp]
 				[/csharp]
 				[/codeblocks]
 				[/codeblocks]
+				[b]Note:[/b] Setting [code]"usage"[/code] for the property is not supported. Use [method set_as_basic], [method set_restart_if_changed], and [method set_as_internal] to modify usage flags.
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="clear">
 		<method name="clear">

+ 6 - 2
editor/editor_settings.cpp

@@ -324,8 +324,12 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
 }
 }
 
 
 void EditorSettings::_add_property_info_bind(const Dictionary &p_info) {
 void EditorSettings::_add_property_info_bind(const Dictionary &p_info) {
-	ERR_FAIL_COND(!p_info.has("name"));
-	ERR_FAIL_COND(!p_info.has("type"));
+	ERR_FAIL_COND_MSG(!p_info.has("name"), "Property info is missing \"name\" field.");
+	ERR_FAIL_COND_MSG(!p_info.has("type"), "Property info is missing \"type\" field.");
+
+	if (p_info.has("usage")) {
+		WARN_PRINT("\"usage\" is not supported in add_property_info().");
+	}
 
 
 	PropertyInfo pinfo;
 	PropertyInfo pinfo;
 	pinfo.name = p_info["name"];
 	pinfo.name = p_info["name"];