[glibmm] Glib::Variant: Fix memory leaks.
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Glib::Variant: Fix memory leaks.
- Date: Sat, 27 Jul 2013 09:56:07 +0000 (UTC)
commit 26c60d3f2f454f41785049e60645c9b6535fc172
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Sat Jul 27 10:54:06 2013 +0200
Glib::Variant: Fix memory leaks.
* glib/src/variant.[hg|ccg]: Call g_variant_builder_unref(). Don't take
extra ref on objects returned from g_variant_get_child_value() or
g_variant_get_variant(). Bug #704851.
glib/src/variant.ccg | 2 ++
glib/src/variant.hg | 8 ++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index dea7391..7b69c2c 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -387,6 +387,8 @@ Variant<type_vec_ustring>::create(const type_vec_ustring& data)
Variant<type_vec_ustring>(g_variant_new(
array_variant_type.get_string().c_str(), builder));
+ g_variant_builder_unref(builder);
+
return result;
}
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index 8a4e3a4..5cb7a1c 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -360,7 +360,7 @@ public:
void get_child(VariantBase& child, gsize index = 0) const;
_IGNORE(g_variant_get_child, g_variant_get_child_value)
-#m4 _CONVERSION(`GVariant*',`VariantBase',`Glib::wrap($3, true)')
+#m4 _CONVERSION(`GVariant*',`VariantBase',`Glib::wrap($3)')
_WRAP_METHOD(VariantBase get_child(gsize index = 0), g_variant_get_child_value)
@@ -988,7 +988,7 @@ template<class T>
Variant<T> Variant< Variant<T> >::get() const
{
GVariant* const gvariant = g_variant_get_variant(gobject_);
- return Variant<T>(gvariant, true);
+ return Variant<T>(gvariant);
}
/*--------------------Variant< std::pair<K, V> >---------------------*/
@@ -1071,6 +1071,8 @@ Variant< std::vector<T> >::create(const std::vector<T>& data)
Variant< std::vector<T> >(g_variant_new(
reinterpret_cast<gchar*>(array_variant_type.gobj()), builder));
+ g_variant_builder_unref(builder);
+
return result;
}
@@ -1168,6 +1170,8 @@ Variant< std::map<K, V> >::create(const std::map<K, V>& data)
Variant< std::map<K, V> > result = Variant< std::map<K, V> >(g_variant_new(
reinterpret_cast<gchar*>(array_variant_type.gobj()), builder));
+ g_variant_builder_unref(builder);
+
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]