Skip to content

Commit b334fc4

Browse files
committedMay 30, 2019
Update for c++11
1 parent e1bd4e9 commit b334fc4

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed
 

‎src/core/pal/feature.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,10 +1152,10 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
11521152
return 0;
11531153

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

11701170
if ( qgsDoubleNear( total_distance, 0.0 ) )
11711171
{
1172-
delete[] path_distances;
11731172
return 0;
11741173
}
11751174

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

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

1211-
LabelPosition *slp = curvedPlacementAtOffset( mapShape, path_distances, orientation, 1, i, reversed, flip );
1209+
LabelPosition *slp = curvedPlacementAtOffset( mapShape, path_distances.get(), orientation, 1, i, reversed, flip );
12121210
if ( !slp )
12131211
continue;
12141212

@@ -1220,7 +1218,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
12201218
{
12211219
delete slp;
12221220
orientation = -orientation;
1223-
slp = curvedPlacementAtOffset( mapShape, path_distances, orientation, 1, i, reversed, flip );
1221+
slp = curvedPlacementAtOffset( mapShape, path_distances.get(), orientation, 1, i, reversed, flip );
12241222
}
12251223
}
12261224
if ( !slp )
@@ -1306,8 +1304,6 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
13061304
lPos << positions.takeFirst();
13071305
}
13081306

1309-
delete[] path_distances;
1310-
13111307
return nbp;
13121308
}
13131309

0 commit comments

Comments
 (0)
Please sign in to comment.