Fix crash open opening Add Metadata dialog
This commit is contained in:
parent
95df3e7c88
commit
372e4cfd49
1 changed files with 9 additions and 15 deletions
|
@ -3983,13 +3983,7 @@ void EditorInspector::_check_meta_name(const String &p_name) {
|
|||
} else if (!p_name.is_valid_identifier()) {
|
||||
error = TTR("Metadata name must be a valid identifier.");
|
||||
} else if (object->has_meta(p_name)) {
|
||||
Node *node = Object::cast_to<Node>(object);
|
||||
if (node) {
|
||||
error = vformat(TTR("Metadata with name \"%s\" already exists on \"%s\"."), p_name, node->get_name());
|
||||
} else {
|
||||
// This should normally never be reached, but the error is set just in case.
|
||||
error = vformat(TTR("Metadata with name \"%s\" already exists."), p_name, node->get_name());
|
||||
}
|
||||
error = vformat(TTR("Metadata with name \"%s\" already exists."), p_name);
|
||||
} else if (p_name[0] == '_') {
|
||||
error = TTR("Names starting with _ are reserved for editor-only metadata.");
|
||||
}
|
||||
|
@ -4009,14 +4003,6 @@ void EditorInspector::_show_add_meta_dialog() {
|
|||
if (!add_meta_dialog) {
|
||||
add_meta_dialog = memnew(ConfirmationDialog);
|
||||
|
||||
Node *node = Object::cast_to<Node>(object);
|
||||
if (node) {
|
||||
add_meta_dialog->set_title(vformat(TTR("Add Metadata Property for \"%s\""), node->get_name()));
|
||||
} else {
|
||||
// This should normally never be reached, but the title is set just in case.
|
||||
add_meta_dialog->set_title(vformat(TTR("Add Metadata Property"), node->get_name()));
|
||||
}
|
||||
|
||||
VBoxContainer *vbc = memnew(VBoxContainer);
|
||||
add_meta_dialog->add_child(vbc);
|
||||
HBoxContainer *hbc = memnew(HBoxContainer);
|
||||
|
@ -4046,6 +4032,14 @@ void EditorInspector::_show_add_meta_dialog() {
|
|||
add_meta_name->connect("text_changed", callable_mp(this, &EditorInspector::_check_meta_name));
|
||||
}
|
||||
|
||||
Node *node = Object::cast_to<Node>(object);
|
||||
if (node) {
|
||||
add_meta_dialog->set_title(vformat(TTR("Add Metadata Property for \"%s\""), node->get_name()));
|
||||
} else {
|
||||
// This should normally be reached when the object is derived from Resource.
|
||||
add_meta_dialog->set_title(vformat(TTR("Add Metadata Property for \"%s\""), object->get_class()));
|
||||
}
|
||||
|
||||
add_meta_dialog->popup_centered();
|
||||
add_meta_name->set_text("");
|
||||
_check_meta_name("");
|
||||
|
|
Loading…
Reference in a new issue