summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-04-07 21:18:46 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-04-07 21:18:46 -0300
commit22997294fa87a1346ef4617b887953a356943354 (patch)
treeb6fc6dbd3357613372b24e1b07f37e87aee83bbc
parentb36e41cb7117757011e6f1ccc476ccc806219a58 (diff)
-Concatenating arrays keeps the shared property if any of the arrays is shared. Fixes #1646
-rw-r--r--bin/tests/test_gui.cpp4
-rw-r--r--core/variant_call.cpp2
-rw-r--r--core/variant_op.cpp2
-rw-r--r--modules/gdscript/gd_parser.cpp1
4 files changed, 6 insertions, 3 deletions
diff --git a/bin/tests/test_gui.cpp b/bin/tests/test_gui.cpp
index 70cff12c44..afcd89c139 100644
--- a/bin/tests/test_gui.cpp
+++ b/bin/tests/test_gui.cpp
@@ -132,7 +132,7 @@ public:
frame->add_child( button );
-
+#if 0
Sprite *tf = memnew( Sprite );
frame->add_child(tf);
Image img;
@@ -147,7 +147,7 @@ public:
tf->set_pos(Point2(50,50));
//tf->set_scale(Point2(0.3,0.3));
-#if 0
+
return;
#endif
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index c6b498ff28..a6b931127a 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -426,6 +426,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0(Array,sort);
VCALL_LOCALMEM2(Array,sort_custom);
VCALL_LOCALMEM0(Array,invert);
+ VCALL_LOCALMEM0R(Array,is_shared);
static void _call_ByteArray_get_string_from_ascii(Variant& r_ret,Variant& p_self,const Variant** p_args) {
@@ -1378,6 +1379,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(ARRAY,NIL,Array,sort,varray());
ADDFUNC2(ARRAY,NIL,Array,sort_custom,OBJECT,"obj",STRING,"func",varray());
ADDFUNC0(ARRAY,NIL,Array,invert,varray());
+ ADDFUNC0(ARRAY,BOOL,Array,is_shared,varray());
ADDFUNC0(RAW_ARRAY,INT,ByteArray,size,varray());
ADDFUNC2(RAW_ARRAY,NIL,ByteArray,set,INT,"idx",INT,"byte",varray());
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 87d9738b06..ba8000b92d 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -471,7 +471,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
}
const Array &array_a=*reinterpret_cast<const Array *>(p_a._data._mem);
const Array &array_b=*reinterpret_cast<const Array *>(p_b._data._mem);
- Array sum;
+ Array sum(array_a.is_shared() || array_b.is_shared());
int asize=array_a.size();
int bsize=array_b.size();
sum.resize(asize+bsize);
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index aa2878f9e1..eae754cbac 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -1075,6 +1075,7 @@ GDParser::Node* GDParser::_reduce_expression(Node *p_node,bool p_to_const) {
ConstantNode *cn = alloc_node<ConstantNode>();
Array arr(!p_to_const);
+ //print_line("mk array "+itos(!p_to_const));
arr.resize(an->elements.size());
for(int i=0;i<an->elements.size();i++) {
ConstantNode *acn = static_cast<ConstantNode*>(an->elements[i]);