]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use if-clause for is_in_destructor() condition to be more clear
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 18 Apr 2021 19:02:21 +0000 (21:02 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 28 Apr 2021 06:47:42 +0000 (08:47 +0200)
codegen/valaccodebasemodule.vala

index d746f60506f79acb9c26714485e21046a7f71820..c00ddc7be18131199fdd5eb94381f3a4d1a8da9f 100644 (file)
@@ -2193,11 +2193,15 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                                unowned DataType? this_type = get_this_type ();
                                if (this_type != null && (!in_creation_method_with_chainup || current_method.body != b)) {
-                                       var ref_call = new CCodeFunctionCall (get_dup_func_expression (this_type, b.source_reference));
-                                       ref_call.add_argument (get_this_cexpression ());
-
-                                       // never increase reference count for self in finalizers to avoid infinite recursion on following unref
-                                       var instance = (is_in_destructor () ? (CCodeExpression) new CCodeIdentifier ("self") : (CCodeExpression) ref_call);
+                                       CCodeExpression instance;
+                                       if (is_in_destructor ()) {
+                                               // never increase reference count for self in finalizers to avoid infinite recursion on following unref
+                                               instance = new CCodeIdentifier ("self");
+                                       } else {
+                                               var ref_call = new CCodeFunctionCall (get_dup_func_expression (this_type, b.source_reference));
+                                               ref_call.add_argument (get_this_cexpression ());
+                                               instance = ref_call;
+                                       }
 
                                        ccode.add_assignment (new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (block_id)), "self"), instance);
                                }