[Marble-commits] KDE/kdeedu/marble/src/lib
Jens-Michael Hoffmann
jensmh at gmx.de
Mon Apr 26 12:28:45 CEST 2010
SVN commit 1118972 by jmhoffmann:
TileCoordsPyramid: fix potential crash.
TileCoordsPyramid has got dynamically allocated data members and so needs to
define a copy constructor and an assignment operator especially since
TileCoordsPyramid objects are copied in existing code.
M +19 -0 TileCoordsPyramid.cpp
M +4 -1 TileCoordsPyramid.h
--- trunk/KDE/kdeedu/marble/src/lib/TileCoordsPyramid.cpp #1118971:1118972
@@ -13,6 +13,8 @@
#include "TileCoordsPyramid.h"
+#include <algorithm>
+
namespace Marble
{
@@ -39,6 +41,18 @@
{
}
+TileCoordsPyramid::TileCoordsPyramid( TileCoordsPyramid const & other )
+ : d( new Private( *other.d ))
+{
+}
+
+TileCoordsPyramid & TileCoordsPyramid::operator=( TileCoordsPyramid const & rhs )
+{
+ TileCoordsPyramid temp( rhs );
+ swap( temp );
+ return *this;
+}
+
TileCoordsPyramid::~TileCoordsPyramid()
{
delete d;
@@ -84,4 +98,9 @@
return result;
}
+void TileCoordsPyramid::swap( TileCoordsPyramid & other )
+{
+ std::swap( d, other.d );
}
+
+}
--- trunk/KDE/kdeedu/marble/src/lib/TileCoordsPyramid.h #1118971:1118972
@@ -24,6 +24,8 @@
{
public:
TileCoordsPyramid( int const topLevel, int const bottomLevel );
+ TileCoordsPyramid( TileCoordsPyramid const & other );
+ TileCoordsPyramid & operator=( TileCoordsPyramid const & rhs );
~TileCoordsPyramid();
int topLevel() const;
@@ -33,8 +35,9 @@
qint64 tilesCount() const;
private:
+ void swap( TileCoordsPyramid & other );
class Private;
- Private * const d;
+ Private * d; // not const, needs to be swapable
};
}
More information about the Marble-commits
mailing list