瀏覽代碼

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!

Juan Linietsky 8 年之前
父節點
當前提交
10938e8bb9
共有 2 個文件被更改,包括 5 次插入2 次删除
  1. 1 1
      core/variant.cpp
  2. 4 1
      tools/editor/create_dialog.cpp

+ 1 - 1
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);

+ 4 - 1
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)) {