Skip to content

Commit

Permalink
Update for c++11
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 30, 2019
1 parent e1bd4e9 commit b334fc4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/core/pal/feature.cpp
Expand Up @@ -1152,10 +1152,10 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
return 0;

// distance calculation
double *path_distances = new double[mapShape->nbPoints];
std::unique_ptr< double [] > path_distances = qgis::make_unique<double[]>( mapShape->nbPoints );
double total_distance = 0;
double old_x = -1.0, old_y = -1.0;
for ( int i = 0; i < mapShape->nbPoints; i++ )
for ( std::size_t i = 0; i < mapShape->nbPoints; i++ )
{
if ( i == 0 )
path_distances[i] = 0;
Expand All @@ -1169,7 +1169,6 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos

if ( qgsDoubleNear( total_distance, 0.0 ) )
{
delete[] path_distances;
return 0;
}

Expand All @@ -1181,7 +1180,6 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
{
// label doesn't fit on this line, don't waste time trying to make candidates
// TODO - in future allow this, and allow label to overlap end of line
delete[] path_distances;
return 0;
}

Expand All @@ -1208,7 +1206,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
orientation = 1;
}

LabelPosition *slp = curvedPlacementAtOffset( mapShape, path_distances, orientation, 1, i, reversed, flip );
LabelPosition *slp = curvedPlacementAtOffset( mapShape, path_distances.get(), orientation, 1, i, reversed, flip );
if ( !slp )
continue;

Expand All @@ -1220,7 +1218,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
{
delete slp;
orientation = -orientation;
slp = curvedPlacementAtOffset( mapShape, path_distances, orientation, 1, i, reversed, flip );
slp = curvedPlacementAtOffset( mapShape, path_distances.get(), orientation, 1, i, reversed, flip );
}
}
if ( !slp )
Expand Down Expand Up @@ -1306,8 +1304,6 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
lPos << positions.takeFirst();
}

delete[] path_distances;

return nbp;
}

Expand Down

0 comments on commit b334fc4

Please sign in to comment.