From 10938e8bb9f72b235bc6609e6b50e6f6d9aee6a5 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 8 Jan 2017 17:23:04 -0300 Subject: [PATCH] Made Variant::NIL printable as "Null". Please everyone be on the lookout of bugs related to assigning an empty variant to a string, and expecting it to be not empty! --- core/variant.cpp | 2 +- tools/editor/create_dialog.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/variant.cpp b/core/variant.cpp index f2c614e14f4..6b504438542 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1502,7 +1502,7 @@ Variant::operator String() const { switch( type ) { - case NIL: return ""; + case NIL: return "Null"; case BOOL: return _data._bool ? "True" : "False"; case INT: return String::num(_data._int); case REAL: return String::num(_data._real); diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index 313b1ad1822..1b1d5f3a4e8 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -400,8 +400,11 @@ Object *CreateDialog::instance_selected() { if (selected) { - String custom = selected->get_metadata(0); + Variant md = selected->get_metadata(0); + String custom; + if (md.get_type()!=Variant::NIL) + custom=md; if (custom!=String()) { if (EditorNode::get_editor_data().get_custom_types().has(custom)) {