[vala/0.14] codegen: Destroy the elements of GQueue
- From: JÃrg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.14] codegen: Destroy the elements of GQueue
- Date: Wed, 30 Nov 2011 14:26:36 +0000 (UTC)
commit 2e1deabc03564e17f8f2e4e2d21e6903b679057c
Author: Luca Bruno <lucabru src gnome org>
Date: Tue Nov 22 15:44:07 2011 +0100
codegen: Destroy the elements of GQueue
When destroying a GQueue also destroy its elements like we do with GList,
GSList and GNode.
Fixes bug 664529.
codegen/valaccodebasemodule.vala | 8 ++++++--
tests/Makefile.am | 1 +
tests/objects/bug664529.vala | 7 +++++++
3 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index d18b269..dd934f6 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -300,6 +300,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public Class glist_type;
public Class gslist_type;
public Class gnode_type;
+ public Class gqueue_type;
public Class gvaluearray_type;
public TypeSymbol gstringbuilder_type;
public TypeSymbol garray_type;
@@ -440,6 +441,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
glist_type = (Class) glib_ns.scope.lookup ("List");
gslist_type = (Class) glib_ns.scope.lookup ("SList");
gnode_type = (Class) glib_ns.scope.lookup ("Node");
+ gqueue_type = (Class) glib_ns.scope.lookup ("Queue");
gvaluearray_type = (Class) glib_ns.scope.lookup ("ValueArray");
gstringbuilder_type = (TypeSymbol) glib_ns.scope.lookup ("StringBuilder");
garray_type = (TypeSymbol) glib_ns.scope.lookup ("Array");
@@ -2768,7 +2770,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public CCodeExpression? get_destroy_func_expression (DataType type, bool is_chainup = false) {
- if (context.profile == Profile.GOBJECT && (type.data_type == glist_type || type.data_type == gslist_type || type.data_type == gnode_type)) {
+ if (context.profile == Profile.GOBJECT && (type.data_type == glist_type || type.data_type == gslist_type || type.data_type == gnode_type || type.data_type == gqueue_type)) {
// create wrapper function to free list elements if necessary
bool elements_require_free = false;
@@ -2896,8 +2898,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
} else {
if (collection_type.data_type == glist_type) {
element_free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_list_foreach"));
- } else {
+ } else if (collection_type.data_type == gslist_type) {
element_free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_slist_foreach"));
+ } else {
+ element_free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_queue_foreach"));
}
element_free_call.add_argument (new CCodeIdentifier ("self"));
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a207501..d4e1af1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -113,6 +113,7 @@ TESTS = \
objects/bug646792.vala \
objects/bug653138.vala \
objects/bug654702.vala \
+ objects/bug664529.vala \
errors/errors.vala \
errors/bug567181.vala \
errors/bug579101.vala \
diff --git a/tests/objects/bug664529.vala b/tests/objects/bug664529.vala
new file mode 100644
index 0000000..1daa493
--- /dev/null
+++ b/tests/objects/bug664529.vala
@@ -0,0 +1,7 @@
+void main() {
+ var foo = new Object ();
+ var bar = new Queue<Object> ();
+ bar.push_head (foo);
+ bar = null;
+ assert (foo.ref_count == 1);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]