[glibmm] Variant: Remove floating reference on creation.
- From: José Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Variant: Remove floating reference on creation.
- Date: Tue, 26 Oct 2010 07:09:32 +0000 (UTC)
commit 8802e749dfe9986c5967e77730fb7bed3e4c2a21
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Tue Oct 26 03:05:11 2010 -0400
Variant: Remove floating reference on creation.
* glib/src/variant.ccg:
* glib/src/variant_basictypes.cc.m4: Modify all create methods of the
variant classes so that they remove the floating reference of the
newly created GVariants. The C API sometimes 'consumes' GVariants
with floating references (see g_dbus_proxy_call()) so this allows C++
to worry about deleting GVariants when their references are all lost.
ChangeLog | 11 +++++++++++
glib/src/variant.ccg | 15 +++++++++++++--
glib/src/variant_basictypes.cc.m4 | 7 ++++++-
3 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7ce9930..c02ba7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2010-10-26 José Alburquerque <jaalburqu svn gnome org>
+ Variant: Remove floating reference on creation.
+
+ * glib/src/variant.ccg:
+ * glib/src/variant_basictypes.cc.m4: Modify all create methods of the
+ variant classes so that they remove the floating reference of the
+ newly created GVariants. The C API sometimes 'consumes' GVariants
+ with floating references (see g_dbus_proxy_call()) so this allows C++
+ to worry about deleting GVariants when their references are all lost.
+
+2010-10-26 José Alburquerque <jaalburqu svn gnome org>
+
DBusProxy: Wrap properites and signals.
* tools/extra_defs_gen/generate_defs_gio.cc: Add a new section for
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index f7808ac..1b94bf6 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -74,7 +74,12 @@ const GVariantType* Variant<VariantBase>::variant_type()
Variant<VariantBase> Variant<VariantBase>::create(const VariantBase& data)
{
- return Variant<VariantBase>(g_variant_new_variant(const_cast<GVariant*>(data.gobj())));
+ Variant<VariantBase> result = Variant<VariantBase>(g_variant_new_variant(const_cast<GVariant*>(data.gobj())));
+
+ // Remove the floating reference (since it is newly created).
+ g_variant_ref_sink(result.gobj());
+
+ return result;
}
VariantBase Variant<VariantBase>::get() const
@@ -91,7 +96,13 @@ const GVariantType* Variant<Glib::ustring>::variant_type()
Variant<Glib::ustring>
Variant<Glib::ustring>::create(const Glib::ustring& data)
{
- return Variant<Glib::ustring>(g_variant_new_string(data.c_str()));
+ Variant<Glib::ustring> result =
+ Variant<Glib::ustring>(g_variant_new_string(data.c_str()));
+
+ // Remove the floating reference (since it is newly created).
+ g_variant_ref_sink(result.gobj());
+
+ return result;
}
Glib::ustring Variant<Glib::ustring>::get() const
diff --git a/glib/src/variant_basictypes.cc.m4 b/glib/src/variant_basictypes.cc.m4
index eb70222..9dea5f2 100644
--- a/glib/src/variant_basictypes.cc.m4
+++ b/glib/src/variant_basictypes.cc.m4
@@ -43,7 +43,12 @@ const GVariantType* Variant<$1>::variant_type()
Variant<$1> Variant<$1>::create($1 data)
{
- return Variant<$1>(g_variant_new_$3(data));
+ Variant<$1> result = Variant<$1>(g_variant_new_$3(data));
+
+ // Remove the floating reference (since it is newly created).
+ g_variant_ref_sink(result.gobj());
+
+ return result;
}
$1 Variant<$1>::get() const
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]