From 22997294fa87a1346ef4617b887953a356943354 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 7 Apr 2015 21:18:46 -0300 Subject: -Concatenating arrays keeps the shared property if any of the arrays is shared. Fixes #1646 --- bin/tests/test_gui.cpp | 4 ++-- core/variant_call.cpp | 2 ++ core/variant_op.cpp | 2 +- modules/gdscript/gd_parser.cpp | 1 + 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(p_a._data._mem); const Array &array_b=*reinterpret_cast(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(); Array arr(!p_to_const); + //print_line("mk array "+itos(!p_to_const)); arr.resize(an->elements.size()); for(int i=0;ielements.size();i++) { ConstantNode *acn = static_cast(an->elements[i]); -- cgit v1.2.3