[Marble-commits] KDE/kdeedu/marble/src/lib/geodata/data
Bastian Holst
bastianholst at gmx.de
Fri May 21 23:13:07 CEST 2010
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
More information about the Marble-commits
mailing list