@@ -1152,10 +1152,10 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
1152
1152
return 0 ;
1153
1153
1154
1154
// distance calculation
1155
- double * path_distances = new double [mapShape->nbPoints ] ;
1155
+ std::unique_ptr< double [] > path_distances = qgis::make_unique< double []>( mapShape->nbPoints ) ;
1156
1156
double total_distance = 0 ;
1157
1157
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++ )
1159
1159
{
1160
1160
if ( i == 0 )
1161
1161
path_distances[i] = 0 ;
@@ -1169,7 +1169,6 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
1169
1169
1170
1170
if ( qgsDoubleNear ( total_distance, 0.0 ) )
1171
1171
{
1172
- delete[] path_distances;
1173
1172
return 0 ;
1174
1173
}
1175
1174
@@ -1181,7 +1180,6 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
1181
1180
{
1182
1181
// label doesn't fit on this line, don't waste time trying to make candidates
1183
1182
// TODO - in future allow this, and allow label to overlap end of line
1184
- delete[] path_distances;
1185
1183
return 0 ;
1186
1184
}
1187
1185
@@ -1208,7 +1206,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
1208
1206
orientation = 1 ;
1209
1207
}
1210
1208
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 );
1212
1210
if ( !slp )
1213
1211
continue ;
1214
1212
@@ -1220,7 +1218,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
1220
1218
{
1221
1219
delete slp;
1222
1220
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 );
1224
1222
}
1225
1223
}
1226
1224
if ( !slp )
@@ -1306,8 +1304,6 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
1306
1304
lPos << positions.takeFirst ();
1307
1305
}
1308
1306
1309
- delete[] path_distances;
1310
-
1311
1307
return nbp;
1312
1308
}
1313
1309
0 commit comments