[Marble-devel] [marble] src/lib/geodata/data: Fix a memory leak occuring because of invalid reference counts.
Dennis Nienhüser
earthwings at gentoo.org
Fri May 6 00:43:21 CEST 2011
Git commit 4becdef10ba12dc3c16e6aa02b74271d79de5687 by Dennis Nienhüser.
Committed on 06/05/2011 at 00:35.
Pushed by nienhueser into branch 'master'.
Fix a memory leak occuring because of invalid reference counts.
Problem reported by Konrad Enzensberger, thanks!
CCMAIL: e.konrad at mpegcode.com
CCMAIL: marble-devel at kde.org
M +3 -0 src/lib/geodata/data/GeoDataCoordinates.cpp
M +4 -4 src/lib/geodata/data/GeoDataCoordinates_p.h
http://commits.kde.org/marble/4becdef10ba12dc3c16e6aa02b74271d79de5687
diff --git a/src/lib/geodata/data/GeoDataCoordinates.cpp b/src/lib/geodata/data/GeoDataCoordinates.cpp
index 1f37b64..e31018d 100644
--- a/src/lib/geodata/data/GeoDataCoordinates.cpp
+++ b/src/lib/geodata/data/GeoDataCoordinates.cpp
@@ -36,6 +36,7 @@ GeoDataCoordinates::Notation GeoDataCoordinates::s_notation = GeoDataCoordinates
GeoDataCoordinates::GeoDataCoordinates( qreal _lon, qreal _lat, qreal _alt, GeoDataCoordinates::Unit unit, int _detail )
: d( new GeoDataCoordinatesPrivate( _lon, _lat, _alt, unit, _detail ) )
{
+ d->ref.ref();
}
/* simply copy the d pointer
@@ -54,6 +55,7 @@ GeoDataCoordinates::GeoDataCoordinates( const GeoDataCoordinates& other )
GeoDataCoordinates::GeoDataCoordinates()
: d( new GeoDataCoordinatesPrivate() )
{
+ d->ref.ref();
}
/*
@@ -87,6 +89,7 @@ void GeoDataCoordinates::detach()
delete d;
d = new_d;
+ d->ref.ref();
}
/*
diff --git a/src/lib/geodata/data/GeoDataCoordinates_p.h b/src/lib/geodata/data/GeoDataCoordinates_p.h
index f97a775..6f60cc4 100644
--- a/src/lib/geodata/data/GeoDataCoordinates_p.h
+++ b/src/lib/geodata/data/GeoDataCoordinates_p.h
@@ -32,7 +32,7 @@ class GeoDataCoordinatesPrivate
m_lat( 0 ),
m_altitude( 0 ),
m_detail( 0 ),
- ref( 1 )
+ ref( 0 )
{
}
@@ -48,7 +48,7 @@ class GeoDataCoordinatesPrivate
int _detail )
: m_altitude( _alt ),
m_detail( _detail ),
- ref( 1 )
+ ref( 0 )
{
switch( unit ){
default:
@@ -74,7 +74,7 @@ class GeoDataCoordinatesPrivate
m_lat( other.m_lat ),
m_altitude( other.m_altitude ),
m_detail( other.m_detail ),
- ref( other.ref )
+ ref( 0 )
{
m_q.set( m_lon, m_lat );
}
@@ -89,7 +89,7 @@ class GeoDataCoordinatesPrivate
m_altitude = other.m_altitude;
m_detail = other.m_detail;
m_q.set( m_lon, m_lat );
- ref = other.ref;
+ ref = 0;
return *this;
}
More information about the Marble-devel
mailing list