[libgdamm] Value: operator=(): Check for identical instance.



commit 473be9e31872b77124d973637adf424e39e6d291
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Sep 21 08:50:17 2011 +0200

    Value: operator=(): Check for identical instance.
    
    * libgda/libgdamm/value.cc: This is generally a good idea in operator=()
    implementations.

 ChangeLog                |    7 +++++++
 libgda/libgdamm/value.cc |    3 +++
 2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 897c2d7..2db18d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-09-21  Murray Cumming  <murrayc murrayc com>
+
+	Value: operator=(): Check for identical instance.
+
+	* libgda/libgdamm/value.cc: This is generally a good idea in operator=()
+	implementations.
+
 2011-09-20  Murray Cumming  <murrayc murrayc com>
 
 	Value: operator=(): Check for the identical underlying GValue.
diff --git a/libgda/libgdamm/value.cc b/libgda/libgdamm/value.cc
index fb1cad3..248bc1b 100644
--- a/libgda/libgdamm/value.cc
+++ b/libgda/libgdamm/value.cc
@@ -216,6 +216,9 @@ Value::Value(const GValue* castitem)
 
 Value& Value::operator=(const Value& src)
 {
+  if(this == &src)
+    return *this;
+
   //Avoid doing anything if no change is necessary:
   if(gobj() == src.gobj())
     return *this;



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