[glibmm] Variant: Don't refsink variants created using the custom cast ctor.



commit 5596d9f3ddca6942d632c85f1cbed475e0a766a8
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date:   Tue Nov 6 20:25:39 2012 -0500

    Variant: Don't refsink variants created using the custom cast ctor.
    
    	* glib/src/variant.ccg:
    	* glib/src/variant.hg:
    	* glib/src/variant_basictypes.cc.m4: Remove the call to
    	g_variant_ref_sink() in the create() methods of the variant types that
    	use the custom cast constructor to wrap the newly created C object
    	because the custom cast constructor already refsinks the object if
    	necessary.

 ChangeLog                         |   12 ++++++++++++
 glib/src/variant.ccg              |   32 --------------------------------
 glib/src/variant.hg               |    9 ---------
 glib/src/variant_basictypes.cc.m4 |    4 ----
 4 files changed, 12 insertions(+), 45 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1917884..0c12be0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2012-11-06  Josà Alburquerque  <jaalburquerque gmail com>
 
+	Variant: Don't refsink variants created using the custom cast ctor.
+
+	* glib/src/variant.ccg:
+	* glib/src/variant.hg:
+	* glib/src/variant_basictypes.cc.m4: Remove the call to
+	g_variant_ref_sink() in the create() methods of the variant types that
+	use the custom cast constructor to wrap the newly created C object
+	because the custom cast constructor already refsinks the object if
+	necessary.
+
+2012-11-06  Josà Alburquerque  <jaalburquerque gmail com>
+
 	MemoryOutputStream: Add the steal_as_bytes() method.
 
 	* gio/src/memoryoutputstream.{ccg,hg}: Add the method that wraps the
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index e75a17e..b7f4f52 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -112,11 +112,7 @@ VariantContainerBase::create_tuple(const std::vector<VariantBase>& children)
 
   VariantContainerBase result = VariantContainerBase(g_variant_new_tuple(
     var_array, children.size()));
-
-  g_variant_ref_sink(result.gobj());
-
   delete[] var_array;
-
   return result;
 }
 
@@ -136,12 +132,7 @@ VariantContainerBase::create_maybe(const VariantType& child_type,
 {
   GVariant* g_variant = g_variant_new_maybe(child_type.gobj(),
     const_cast<GVariant*>(child.gobj()));
-
   VariantContainerBase result = VariantContainerBase(g_variant);
-
-  // Remove the floating reference (since it is newly created).
-  g_variant_ref_sink(result.gobj());
-
   return result;
 }
 
@@ -221,10 +212,6 @@ const VariantType& Variant<VariantBase>::variant_type()
 Variant<VariantBase> Variant<VariantBase>::create(const VariantBase& data)
 {
   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;
 }
 
@@ -256,10 +243,6 @@ Variant<Glib::ustring>::create(const Glib::ustring& data)
 {
   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;
 }
 
@@ -314,10 +297,6 @@ Variant<std::string>::create(const std::string& data)
 {
   Variant<std::string> result =
     Variant<std::string>(g_variant_new_bytestring(data.c_str()));
-
-  // Remove the floating reference (since it is newly created).
-  g_variant_ref_sink(result.gobj());
-
   return result;
 }
 
@@ -403,9 +382,6 @@ 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));
 
-  // Remove the floating reference (since it is newly created).
-  g_variant_ref_sink(result.gobj());
-
   return result;
 }
 
@@ -493,10 +469,6 @@ Variant<type_vec_string>::create(const type_vec_string& data)
       data.size()));
 
   g_strfreev(str_array);
-
-  // Remove the floating reference (since it is newly created).
-  g_variant_ref_sink(result.gobj());
-
   return result;
 }
 
@@ -521,10 +493,6 @@ Variant<type_vec_string>::create_from_object_paths(const type_vec_string& data)
     Variant<type_vec_string>(g_variant_new_objv(str_array, data.size()));
 
   g_strfreev(str_array);
-
-  // Remove the floating reference (since it is newly created).
-  g_variant_ref_sink(result.gobj());
-
   return result;
 }
 
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index 2caa689..7407d35 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -881,9 +881,6 @@ Variant< std::pair<K, V> >::create(const std::pair<K, V>& data)
   Variant< std::pair<K, V> > result = Variant< std::pair<K, V> >(
     g_variant_new_dict_entry(key.gobj(), value.gobj()));
 
-  // Remove the floating reference (since it is newly created).
-  g_variant_ref_sink(result.gobj());
-
   return result;
 }
 
@@ -941,9 +938,6 @@ 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));
 
-  // Remove the floating reference (since it is newly created).
-  g_variant_ref_sink(result.gobj());
-
   return result;
 }
 
@@ -1033,9 +1027,6 @@ 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));
 
-  // Remove the floating reference (since it is newly created).
-  g_variant_ref_sink(result.gobj());
-
   return result;
 }
 
diff --git a/glib/src/variant_basictypes.cc.m4 b/glib/src/variant_basictypes.cc.m4
index 1b54ac1..ba79a20 100644
--- a/glib/src/variant_basictypes.cc.m4
+++ b/glib/src/variant_basictypes.cc.m4
@@ -45,10 +45,6 @@ const VariantType& Variant<$1>::variant_type()
 Variant<$1> Variant<$1>::create($1 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;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]