Skip to content
Permalink
Browse files

Fix leaks

  • Loading branch information
nyalldawson committed Jun 5, 2016
1 parent fab16ec commit f70be07566925af6304de6495084de64da7f5360
@@ -354,11 +354,11 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
double min = lineEditValue( mMinLineEdit );
double max = lineEditValue( mMaxLineEdit );

QgsVectorColorRampV2* colorRamp = mColorRampComboBox->currentColorRamp();
QScopedPointer< QgsVectorColorRampV2 > colorRamp( mColorRampComboBox->currentColorRamp() );

if ( mClassificationModeComboBox->itemData( mClassificationModeComboBox->currentIndex() ).toInt() == Continuous )
{
if ( colorRamp )
if ( colorRamp.data() )
{
numberOfEntries = colorRamp->count();
entryValues.reserve( numberOfEntries );
@@ -367,7 +367,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
double intervalDiff = max - min;

// remove last class when ColorRamp is gradient and discrete, as they are implemented with an extra stop
QgsVectorGradientColorRampV2* colorGradientRamp = dynamic_cast<QgsVectorGradientColorRampV2*>( colorRamp );
QgsVectorGradientColorRampV2* colorGradientRamp = dynamic_cast<QgsVectorGradientColorRampV2*>( colorRamp.data() );
if ( colorGradientRamp != NULL && colorGradientRamp->isDiscrete() )
{
numberOfEntries--;
@@ -405,7 +405,8 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
else // for other classification modes interpolate colors linearly
{
numberOfEntries = mNumberOfEntriesSpinBox->value();
if ( numberOfEntries < 2 ) return; // < 2 classes is not useful, shouldn't happen, but if it happens save it from crashing
if ( numberOfEntries < 2 )
return; // < 2 classes is not useful, shouldn't happen, but if it happens save it from crashing

if ( mClassificationModeComboBox->itemData( mClassificationModeComboBox->currentIndex() ).toInt() == Quantile )
{ // Quantile
@@ -470,7 +471,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
}
}

if ( ! colorRamp )
if ( !colorRamp.data() )
{
//hard code color range from blue -> red (previous default)
int colorDiff = 0;
@@ -104,12 +104,12 @@ static QgsPointV2* parsePoint( const QVariantList& coordList, QgsWKBTypes::Type
{
int nCoords = coordList.size();
if ( nCoords < 2 )
return 0;
return nullptr;
bool xok = false, yok = false;
double x = coordList[0].toDouble( &xok );
double y = coordList[1].toDouble( &yok );
if ( !xok || !yok )
return 0;
return nullptr;
double z = nCoords >= 3 ? coordList[2].toDouble() : 0;
double m = nCoords >= 4 ? coordList[3].toDouble() : 0;
return new QgsPointV2( pointType, x, y, z, m );
@@ -119,15 +119,16 @@ static QgsCircularStringV2* parseCircularString( const QVariantMap& curveData, Q
{
QVariantList coordsList = curveData["c"].toList();
if ( coordsList.isEmpty() )
return 0;
return nullptr;
QList<QgsPointV2> points;
points.append( startPoint );
foreach ( const QVariant& coordData, coordsList )
{
QgsPointV2* point = parsePoint( coordData.toList(), pointType );
if ( points.last() == 0 )
{
return 0;
delete point;
return nullptr;
}
points.append( *point );
delete point;
@@ -151,7 +152,7 @@ static QgsCompoundCurveV2* parseCompoundCurve( const QVariantList& curvesList, Q
if ( !point )
{
delete compoundCurve;
return 0;
return nullptr;
}
lineString->addVertex( *point );
delete point;
@@ -163,7 +164,7 @@ static QgsCompoundCurveV2* parseCompoundCurve( const QVariantList& curvesList, Q
if ( !circularString )
{
delete compoundCurve;
return 0;
return nullptr;
}

// If the previous curve had less than two points, remove it
@@ -188,7 +189,7 @@ static QgsAbstractGeometryV2* parseEsriGeometryPoint( const QVariantMap& geometr
double x = geometryData["x"].toDouble( &xok );
double y = geometryData["y"].toDouble( &yok );
if ( !xok || !yok )
return 0;
return nullptr;
double z = geometryData["z"].toDouble();
double m = geometryData["m"].toDouble();
return new QgsPointV2( pointType, x, y, z, m );
@@ -199,7 +200,7 @@ static QgsAbstractGeometryV2* parseEsriGeometryMultiPoint( const QVariantMap& ge
// {"points" : [[ <x1>, <y1>, <z1>, <m1> ] , [ <x2>, <y2>, <z2>, <m2> ], ... ]}
QVariantList coordsList = geometryData["points"].toList();
if ( coordsList.isEmpty() )
return 0;
return nullptr;

QgsMultiPointV2* multiPoint = new QgsMultiPointV2();
foreach ( QVariant coordData, coordsList )
@@ -209,7 +210,7 @@ static QgsAbstractGeometryV2* parseEsriGeometryMultiPoint( const QVariantMap& ge
if ( !p )
{
delete multiPoint;
return 0;
return nullptr;
}
multiPoint->addGeometry( p );
}
@@ -225,15 +226,15 @@ static QgsAbstractGeometryV2* parseEsriGeometryPolyline( const QVariantMap& geom
else if ( geometryData["curvePaths"].isValid() )
pathsList = geometryData["curvePaths"].toList();
if ( pathsList.isEmpty() )
return 0;
return nullptr;
QgsMultiCurveV2* multiCurve = new QgsMultiCurveV2();
foreach ( const QVariant& pathData, pathsList )
{
QgsCompoundCurveV2* curve = parseCompoundCurve( pathData.toList(), pointType );
if ( !curve )
{
delete multiCurve;
return 0;
return nullptr;
}
multiCurve->addGeometry( curve );
}
@@ -249,13 +250,13 @@ static QgsAbstractGeometryV2* parseEsriGeometryPolygon( const QVariantMap& geome
else if ( geometryData["ringPaths"].isValid() )
ringsList = geometryData["ringPaths"].toList();
if ( ringsList.isEmpty() )
return 0;
return nullptr;
QgsCurvePolygonV2* polygon = new QgsCurvePolygonV2();
QgsCompoundCurveV2* ext = parseCompoundCurve( ringsList.front().toList(), pointType );
if ( !ext )
{
delete polygon;
return 0;
return nullptr;
}
polygon->setExteriorRing( ext );
for ( int i = 1, n = ringsList.size(); i < n; ++i )
@@ -264,7 +265,7 @@ static QgsAbstractGeometryV2* parseEsriGeometryPolygon( const QVariantMap& geome
if ( !curve )
{
delete polygon;
return 0;
return nullptr;
}
polygon->addInteriorRing( curve );
}
@@ -280,7 +281,7 @@ static QgsAbstractGeometryV2* parseEsriEnvelope( const QVariantMap& geometryData
double xmax = geometryData["xmax"].toDouble( &xmaxOk );
double ymax = geometryData["ymax"].toDouble( &ymaxOk );
if ( !xminOk || !yminOk || !xmaxOk || !ymaxOk )
return 0;
return nullptr;
QgsLineStringV2* ext = new QgsLineStringV2();
ext->addVertex( QgsPointV2( xmin, ymin ) );
ext->addVertex( QgsPointV2( xmax, ymin ) );
@@ -302,7 +303,7 @@ QgsAbstractGeometryV2* QgsArcGisRestUtils::parseEsriGeoJSON( const QVariantMap&

// http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geometry_Objects/02r3000000n1000000/
if ( esriGeometryType == "esriGeometryNull" )
return 0;
return nullptr;
else if ( esriGeometryType == "esriGeometryPoint" )
return parseEsriGeometryPoint( geometryData, pointType );
else if ( esriGeometryType == "esriGeometryMultipoint" )
@@ -328,7 +329,7 @@ QgsAbstractGeometryV2* QgsArcGisRestUtils::parseEsriGeoJSON( const QVariantMap&
// esriGeometrySphere
// esriGeometryTriangles
// esriGeometryBag
return 0;
return nullptr;
}

QgsCoordinateReferenceSystem QgsArcGisRestUtils::parseSpatialReference( const QVariantMap &spatialReferenceMap )

0 comments on commit f70be07

Please sign in to comment.
You can’t perform that action at this time.