From 9f6c0c6eaef754f2049ee536c5b38bfdc65fbd08 Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Fri, 9 Mar 2018 21:16:08 +0200 Subject: Duplicate Arrays and Dictionaries when instancing scene in editor Also, add deep (=false) parameter to Array.duplicate and Dictionary.duplicate Fixes #13971 --- core/array.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'core/array.cpp') diff --git a/core/array.cpp b/core/array.cpp index 0ddac1662..9e3250fd4 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -35,8 +35,8 @@ #include "variant.h" #include "vector.h" -struct ArrayPrivate { - +class ArrayPrivate { +public: SafeRefCount refcount; Vector array; }; @@ -211,13 +211,13 @@ const Variant &Array::get(int p_idx) const { return operator[](p_idx); } -Array Array::duplicate() const { +Array Array::duplicate(bool p_deep) const { Array new_arr; int element_count = size(); new_arr.resize(element_count); for (int i = 0; i < element_count; i++) { - new_arr[i] = get(i); + new_arr[i] = p_deep ? get(i).duplicate(p_deep) : get(i); } return new_arr; -- cgit v1.2.3-70-g09d2