[Vala] [PATCH] Also call g_object_unref for lists of interfaces.
- From: Mathias Hasselmann <mathias hasselmann gmx de>
- To: vala paldo org
- Subject: [Vala] [PATCH] Also call g_object_unref for lists of interfaces.
- Date: Sun, 18 Mar 2007 22:15:46 +0100
Guess any implementation of a GObject interface extends - so it should be
safe to unconditionally use g_object_unref on lists of interfaces.
---
trunk/vala/vala/valacodegenerator.vala | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/trunk/vala/vala/valacodegenerator.vala b/trunk/vala/vala/valacodegenerator.vala
index 3908e06..5f22c67 100644
--- a/trunk/vala/vala/valacodegenerator.vala
+++ b/trunk/vala/vala/valacodegenerator.vala
@@ -2152,16 +2152,18 @@ public class Vala.CodeGenerator : CodeVisitor {
if (unref_function == "g_list_free") {
bool is_ref = false;
bool is_class = false;
- var type_args = type.get_type_arguments ();
- foreach (TypeReference type_arg in type_args) {
- is_ref = type_arg.takes_ownership;
- is_class = type_arg.data_type is Class;
+ bool is_interface = false;
+
+ foreach (TypeReference type_arg in type.get_type_arguments ()) {
+ is_ref |= type_arg.takes_ownership;
+ is_class |= type_arg.data_type is Class;
+ is_interface |= type_arg.data_type is Interface;
}
if (is_ref) {
var cunrefcall = new CCodeFunctionCall (new CCodeIdentifier
("g_list_foreach"));
cunrefcall.add_argument (cvar);
- if (is_class) {
+ if (is_class || is_interface) {
cunrefcall.add_argument (new CCodeIdentifier ("(GFunc)
g_object_unref"));
} else {
cunrefcall.add_argument (new CCodeIdentifier ("(GFunc) g_free"));
--
1.4.4.2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]