[libgdamm/libgdamm-4-2] Value: operator=(): Check for the identical underlying GValue.



commit 7147543aa10f537268646cc632a0678a1e303496
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Sep 20 23:23:30 2011 +0200

    Value: operator=(): Check for the identical underlying GValue.
    
    * libgda/libgdamm/value.cc: Otherwise we unset the gobject, which
    unsets the src, because it is the same gobject, and then we reject that
    src as invalid.

 ChangeLog                |    8 ++++++++
 libgda/libgdamm/value.cc |   11 +++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4ddd1d4..6aa29d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-09-20  Murray Cumming  <murrayc murrayc com>
+
+	Value: operator=(): Check for the identical underlying GValue.
+
+	* libgda/libgdamm/value.cc: Otherwise we unset the gobject, which 
+	unsets the src, because it is the same gobject, and then we reject that
+	src as invalid.
+
 4.1.2:
 
 2011-01-30  Murray Cumming  <murrayc murrayc com>
diff --git a/libgda/libgdamm/value.cc b/libgda/libgdamm/value.cc
index a995427..69e4c5d 100644
--- a/libgda/libgdamm/value.cc
+++ b/libgda/libgdamm/value.cc
@@ -221,10 +221,17 @@ Value::Value(const GValue* castitem)
 
 Value& Value::operator=(const Value& src)
 {
+  //Avoid doing anything if no change is necessary:
+  if(gobj() == src.gobj())
+    return *this;
+
   // Unset current value, if any
-  if(G_IS_VALUE(gobj())) g_value_unset(gobj());
+  if(G_IS_VALUE(gobj()))
+    g_value_unset(gobj());
+
   // Set new value, if any
-  if(G_IS_VALUE(src.gobj())) init(src.gobj());
+  if(G_IS_VALUE(src.gobj()))
+    init(src.gobj());
 
   return *this;
 }



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