summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-08-25 23:09:41 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-08-25 23:09:41 -0300
commitb0be30d9efb11aba10fd97c71fec47e34ea88ca1 (patch)
treee57d8515a5354c4aecb3ceaf4ad4235465fc0c96 /tools
parentd50921b55089e0396ee5f11675b6093dd49b7cbb (diff)
make sure array is created if not existing, as noted by Guilherme Felipe
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/array_property_edit.cpp11
-rw-r--r--tools/editor/array_property_edit.h3
-rw-r--r--tools/editor/property_editor.cpp2
3 files changed, 12 insertions, 4 deletions
diff --git a/tools/editor/array_property_edit.cpp b/tools/editor/array_property_edit.cpp
index 61081b73d1..9cd443270b 100644
--- a/tools/editor/array_property_edit.cpp
+++ b/tools/editor/array_property_edit.cpp
@@ -9,7 +9,12 @@ Variant ArrayPropertyEdit::get_array() const{
Object*o = ObjectDB::get_instance(obj);
if (!o)
return Array();
- return o->get(property);
+ Variant arr=o->get(property);
+ if (!arr.is_array()) {
+ Variant::CallError ce;
+ arr=Variant::construct(default_type,NULL,0,ce);
+ }
+ return arr;
}
void ArrayPropertyEdit::_notif_change() {
@@ -195,11 +200,12 @@ void ArrayPropertyEdit::_get_property_list( List<PropertyInfo> *p_list) const{
}
-void ArrayPropertyEdit::edit(Object* p_obj,const StringName& p_prop) {
+void ArrayPropertyEdit::edit(Object* p_obj,const StringName& p_prop,Variant::Type p_deftype) {
page=0;
property=p_prop;
obj=p_obj->get_instance_ID();
+ default_type=p_deftype;
}
@@ -220,5 +226,6 @@ ArrayPropertyEdit::ArrayPropertyEdit()
vtypes+=",";
vtypes+=Variant::get_type_name( Variant::Type(i) );
}
+ default_type=Variant::NIL;
}
diff --git a/tools/editor/array_property_edit.h b/tools/editor/array_property_edit.h
index 0bf7468eeb..acfb8e68ed 100644
--- a/tools/editor/array_property_edit.h
+++ b/tools/editor/array_property_edit.h
@@ -12,6 +12,7 @@ class ArrayPropertyEdit : public Reference {
StringName property;
String vtypes;
Variant get_array() const;
+ Variant::Type default_type;
void _notif_change();
void _notif_changev(const String& p_v);
@@ -27,7 +28,7 @@ protected:
public:
- void edit(Object* p_obj,const StringName& p_prop);
+ void edit(Object* p_obj, const StringName& p_prop, Variant::Type p_deftype);
ArrayPropertyEdit();
};
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 39b9c72313..7e367e17b8 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -3143,7 +3143,7 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
}
Ref<ArrayPropertyEdit> ape = memnew( ArrayPropertyEdit );
- ape->edit(obj,n);
+ ape->edit(obj,n,Variant::Type(t));
EditorNode::get_singleton()->push_item(ape.ptr());
}