summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-29 14:12:14 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-29 14:12:14 +0100
commit10b47d03c852514f59df934fdf4182f51b2cecb7 (patch)
tree0a32aeed87e3705b00848997b7143b2818a24015
parent21af5733b8e775cf1a97f8fe1f43304f3b2d796c (diff)
parentbfffb8f254c6d53ea54b919c446797c75cdd24e1 (diff)
Merge pull request #71822 from adamscott/fix-resource-duplicate
Fix `Resource::duplicate()` missing packed arrays
-rw-r--r--core/io/resource.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index e44bbc246b..4abcbffb61 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -260,15 +260,35 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const {
}
Variant p = get(E.name);
- if ((p.get_type() == Variant::DICTIONARY || p.get_type() == Variant::ARRAY)) {
- r->set(E.name, p.duplicate(p_subresources));
- } else if (p.get_type() == Variant::OBJECT && !(E.usage & PROPERTY_USAGE_NEVER_DUPLICATE) && (p_subresources || (E.usage & PROPERTY_USAGE_ALWAYS_DUPLICATE))) {
- Ref<Resource> sr = p;
- if (sr.is_valid()) {
- r->set(E.name, sr->duplicate(p_subresources));
+ switch (p.get_type()) {
+ case Variant::Type::DICTIONARY:
+ case Variant::Type::ARRAY:
+ case Variant::Type::PACKED_BYTE_ARRAY:
+ case Variant::Type::PACKED_COLOR_ARRAY:
+ case Variant::Type::PACKED_INT32_ARRAY:
+ case Variant::Type::PACKED_INT64_ARRAY:
+ case Variant::Type::PACKED_FLOAT32_ARRAY:
+ case Variant::Type::PACKED_FLOAT64_ARRAY:
+ case Variant::Type::PACKED_STRING_ARRAY:
+ case Variant::Type::PACKED_VECTOR2_ARRAY:
+ case Variant::Type::PACKED_VECTOR3_ARRAY: {
+ r->set(E.name, p.duplicate(p_subresources));
+ } break;
+
+ case Variant::Type::OBJECT: {
+ if (!(E.usage & PROPERTY_USAGE_NEVER_DUPLICATE) && (p_subresources || (E.usage & PROPERTY_USAGE_ALWAYS_DUPLICATE))) {
+ Ref<Resource> sr = p;
+ if (sr.is_valid()) {
+ r->set(E.name, sr->duplicate(p_subresources));
+ }
+ } else {
+ r->set(E.name, p);
+ }
+ } break;
+
+ default: {
+ r->set(E.name, p);
}
- } else {
- r->set(E.name, p);
}
}