[vala/staging] codegen: Fix (unowned foo)[] to foo[] array copy



commit 53e0f1720fa8e5b99670eeb95f321189f58e92f0
Author: Luca Bruno <lucabru src gnome org>
Date:   Tue Aug 12 23:14:25 2014 +0200

    codegen: Fix (unowned foo)[] to foo[] array copy
    
    Fixes bug 731017

 codegen/valaccodebasemodule.vala |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index dae3334..b16b2f8 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5717,7 +5717,16 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        result.lvalue = result.lvalue && result.cvalue == old_cexpr;
                }
 
-               if (!gvalue_boxing && !gvariant_boxing && target_type.value_owned && (!type.value_owned || 
boxing || unboxing) && requires_copy (target_type) && !(type is NullType)) {
+               bool array_needs_copy = false;
+               if (type is ArrayType && target_type is ArrayType) {
+                       var array = (ArrayType) type;
+                       var target_array = (ArrayType) target_type;
+                       if (target_array.element_type.value_owned && !array.element_type.value_owned) {
+                               array_needs_copy = requires_copy (target_array.element_type);
+                       }
+               }
+               
+               if (!gvalue_boxing && !gvariant_boxing && target_type.value_owned && (!type.value_owned || 
boxing || unboxing || array_needs_copy) && requires_copy (target_type) && !(type is NullType)) {
                        // need to copy value
                        var copy = (GLibValue) copy_value (result, node);
                        if (target_type.data_type is Interface && copy == null) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]