[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/marble/src/lib/geodata/data
From:       Bastian Holst <bastianholst () gmx ! de>
Date:       2010-05-21 21:13:07
Message-ID: 20100521211307.5CB57AC8BC () svn ! kde ! org
[Download RAW message or body]

SVN commit 1129286 by bholst:

GeoDataRegion has now a operator= which is self-assignment safe.

 M  +10 -1     GeoDataRegion.cpp  
 M  +3 -2      GeoDataRegion.h  
 M  +6 -23     GeoDataRegion_p.h  


--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataRegion.cpp #1129285:1129286
@@ -22,7 +22,10 @@
 
 #include "GeoDataTypes.h"
 
+// std
+#include <algorithm>
 
+
 namespace Marble
 {
 GeoDataRegion::GeoDataRegion()
@@ -148,9 +151,15 @@
 
 GeoDataRegion &GeoDataRegion::operator=( const GeoDataRegion& other )
 {
-    *d = *other.d;
+    GeoDataRegion temp( other );
+    swap( temp );
     return *this;
 }
 
+void GeoDataRegion::swap( GeoDataRegion & other )
+{
+    std::swap( d, other.d );
 }
 
+}
+
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataRegion.h #1129285:1129286
@@ -144,8 +144,9 @@
 
     GeoDataRegion &operator=( const GeoDataRegion& other );
 
- protected:
-    GeoDataRegionPrivate  * const d;
+ private:
+    void swap( GeoDataRegion & other );
+    GeoDataRegionPrivate  *d;
 };
 
 }
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataRegion_p.h #1129285:1129286
@@ -71,34 +71,17 @@
         return GeoDataTypes::GeoDataRegionType;
     }
 
-    GeoDataRegionPrivate &operator=( const GeoDataRegionPrivate other )
-    {
-        QMutexLocker locker( &m_mutex );
-        m_parent = other.m_parent;
-        delete m_latLonAltBox;
-        if ( other.m_latLonAltBox ) {
-            m_latLonAltBox = new GeoDataLatLonAltBox( *other.m_latLonAltBox );
-        }
-        else {
-            m_latLonAltBox = 0;
-        }
-
-        delete m_lod;
-        if ( other.m_lod ) {
-            m_lod = new GeoDataLod( *other.m_lod );
-        }
-        else {
-            m_lod = 0;
-        }
-
-        return *this;
-    }
-
     GeoDataFeature * m_parent;
     GeoDataLatLonAltBox * m_latLonAltBox;
     GeoDataLod * m_lod;
 
     QMutex m_mutex;
+
+  private:
+    GeoDataRegionPrivate &operator=( const GeoDataRegionPrivate& )
+    {
+        return *this;
+    }
 };
 
 } // namespace Marble
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic