@@ -75,51 +75,51 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::geomFromWkt( const QStr
75
75
std::unique_ptr< QgsAbstractGeometry> geom;
76
76
if ( trimmed.startsWith ( QLatin1String ( " Point" ), Qt::CaseInsensitive ) )
77
77
{
78
- geom. reset ( new QgsPoint () );
78
+ geom = qgis::make_unique< QgsPoint >( );
79
79
}
80
80
else if ( trimmed.startsWith ( QLatin1String ( " LineString" ), Qt::CaseInsensitive ) )
81
81
{
82
- geom. reset ( new QgsLineString () );
82
+ geom = qgis::make_unique< QgsLineString >( );
83
83
}
84
84
else if ( trimmed.startsWith ( QLatin1String ( " CircularString" ), Qt::CaseInsensitive ) )
85
85
{
86
- geom. reset ( new QgsCircularString () );
86
+ geom = qgis::make_unique< QgsCircularString >( );
87
87
}
88
88
else if ( trimmed.startsWith ( QLatin1String ( " CompoundCurve" ), Qt::CaseInsensitive ) )
89
89
{
90
- geom. reset ( new QgsCompoundCurve () );
90
+ geom = qgis::make_unique< QgsCompoundCurve>( );
91
91
}
92
92
else if ( trimmed.startsWith ( QLatin1String ( " Polygon" ), Qt::CaseInsensitive ) )
93
93
{
94
- geom. reset ( new QgsPolygonV2 () );
94
+ geom = qgis::make_unique< QgsPolygonV2 >( );
95
95
}
96
96
else if ( trimmed.startsWith ( QLatin1String ( " CurvePolygon" ), Qt::CaseInsensitive ) )
97
97
{
98
- geom. reset ( new QgsCurvePolygon () );
98
+ geom = qgis::make_unique< QgsCurvePolygon >( );
99
99
}
100
100
else if ( trimmed.startsWith ( QLatin1String ( " MultiPoint" ), Qt::CaseInsensitive ) )
101
101
{
102
- geom. reset ( new QgsMultiPointV2 () );
102
+ geom = qgis::make_unique< QgsMultiPointV2 >( );
103
103
}
104
104
else if ( trimmed.startsWith ( QLatin1String ( " MultiCurve" ), Qt::CaseInsensitive ) )
105
105
{
106
- geom. reset ( new QgsMultiCurve () );
106
+ geom = qgis::make_unique< QgsMultiCurve >( );
107
107
}
108
108
else if ( trimmed.startsWith ( QLatin1String ( " MultiLineString" ), Qt::CaseInsensitive ) )
109
109
{
110
- geom. reset ( new QgsMultiLineString () );
110
+ geom = qgis::make_unique< QgsMultiLineString >( );
111
111
}
112
112
else if ( trimmed.startsWith ( QLatin1String ( " MultiSurface" ), Qt::CaseInsensitive ) )
113
113
{
114
- geom. reset ( new QgsMultiSurface () );
114
+ geom = qgis::make_unique< QgsMultiSurface >( );
115
115
}
116
116
else if ( trimmed.startsWith ( QLatin1String ( " MultiPolygon" ), Qt::CaseInsensitive ) )
117
117
{
118
- geom. reset ( new QgsMultiPolygonV2 () );
118
+ geom = qgis::make_unique< QgsMultiPolygonV2 >( );
119
119
}
120
120
else if ( trimmed.startsWith ( QLatin1String ( " GeometryCollection" ), Qt::CaseInsensitive ) )
121
121
{
122
- geom. reset ( new QgsGeometryCollection () );
122
+ geom = qgis::make_unique< QgsGeometryCollection >( );
123
123
}
124
124
125
125
if ( geom )
@@ -134,12 +134,12 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::geomFromWkt( const QStr
134
134
135
135
std::unique_ptr< QgsAbstractGeometry > QgsGeometryFactory::fromPoint ( const QgsPointXY &point )
136
136
{
137
- return std::unique_ptr< QgsAbstractGeometry >( new QgsPoint ( point.x (), point.y () ) );
137
+ return qgis::make_unique< QgsPoint >( point.x (), point.y () );
138
138
}
139
139
140
140
std::unique_ptr<QgsMultiPointV2> QgsGeometryFactory::fromMultiPoint ( const QgsMultiPoint &multipoint )
141
141
{
142
- std::unique_ptr< QgsMultiPointV2 > mp ( new QgsMultiPointV2 () );
142
+ std::unique_ptr< QgsMultiPointV2 > mp = qgis::make_unique< QgsMultiPointV2 >( );
143
143
QgsMultiPoint::const_iterator ptIt = multipoint.constBegin ();
144
144
for ( ; ptIt != multipoint.constEnd (); ++ptIt )
145
145
{
@@ -156,7 +156,7 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::fromPolyline( const Qgs
156
156
157
157
std::unique_ptr<QgsMultiLineString> QgsGeometryFactory::fromMultiPolyline ( const QgsMultiPolyline &multiline )
158
158
{
159
- std::unique_ptr< QgsMultiLineString > mLine ( new QgsMultiLineString () );
159
+ std::unique_ptr< QgsMultiLineString > mLine = qgis::make_unique< QgsMultiLineString >( );
160
160
for ( int i = 0 ; i < multiline.size (); ++i )
161
161
{
162
162
mLine ->addGeometry ( fromPolyline ( multiline.at ( i ) ).release () );
@@ -166,7 +166,7 @@ std::unique_ptr<QgsMultiLineString> QgsGeometryFactory::fromMultiPolyline( const
166
166
167
167
std::unique_ptr<QgsPolygonV2> QgsGeometryFactory::fromPolygon ( const QgsPolygon &polygon )
168
168
{
169
- std::unique_ptr< QgsPolygonV2 > poly ( new QgsPolygonV2 () );
169
+ std::unique_ptr< QgsPolygonV2 > poly = qgis::make_unique< QgsPolygonV2 >( );
170
170
171
171
QList<QgsCurve *> holes;
172
172
for ( int i = 0 ; i < polygon.size (); ++i )
@@ -189,7 +189,7 @@ std::unique_ptr<QgsPolygonV2> QgsGeometryFactory::fromPolygon( const QgsPolygon
189
189
190
190
std::unique_ptr< QgsMultiPolygonV2 > QgsGeometryFactory::fromMultiPolygon ( const QgsMultiPolygon &multipoly )
191
191
{
192
- std::unique_ptr< QgsMultiPolygonV2 > mp ( new QgsMultiPolygonV2 () );
192
+ std::unique_ptr< QgsMultiPolygonV2 > mp = qgis::make_unique< QgsMultiPolygonV2 >( );
193
193
for ( int i = 0 ; i < multipoly.size (); ++i )
194
194
{
195
195
mp->addGeometry ( fromPolygon ( multipoly.at ( i ) ).release () );
@@ -209,7 +209,7 @@ std::unique_ptr<QgsLineString> QgsGeometryFactory::linestringFromPolyline( const
209
209
x << it->x ();
210
210
y << it->y ();
211
211
}
212
- std::unique_ptr< QgsLineString > line ( new QgsLineString ( x, y ) );
212
+ std::unique_ptr< QgsLineString > line = qgis::make_unique< QgsLineString > ( x, y );
213
213
return line;
214
214
}
215
215
@@ -219,31 +219,31 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::geomFromWkbType( QgsWkb
219
219
switch ( type )
220
220
{
221
221
case QgsWkbTypes::Point:
222
- return std::unique_ptr<QgsAbstractGeometry>( new QgsPoint () );
222
+ return qgis::make_unique< QgsPoint >( );
223
223
case QgsWkbTypes::LineString:
224
- return std::unique_ptr<QgsAbstractGeometry>( new QgsLineString () );
224
+ return qgis::make_unique< QgsLineString >( );
225
225
case QgsWkbTypes::CircularString:
226
- return std::unique_ptr<QgsAbstractGeometry>( new QgsCircularString () );
226
+ return qgis::make_unique< QgsCircularString >( );
227
227
case QgsWkbTypes::CompoundCurve:
228
- return std::unique_ptr<QgsAbstractGeometry>( new QgsCompoundCurve () );
228
+ return qgis::make_unique< QgsCompoundCurve >( );
229
229
case QgsWkbTypes::Polygon:
230
- return std::unique_ptr<QgsAbstractGeometry>( new QgsPolygonV2 () );
230
+ return qgis::make_unique< QgsPolygonV2 >( );
231
231
case QgsWkbTypes::CurvePolygon:
232
- return std::unique_ptr<QgsAbstractGeometry>( new QgsCurvePolygon () );
232
+ return qgis::make_unique< QgsCurvePolygon >( );
233
233
case QgsWkbTypes::MultiLineString:
234
- return std::unique_ptr<QgsAbstractGeometry>( new QgsMultiLineString () );
234
+ return qgis::make_unique< QgsMultiLineString >( );
235
235
case QgsWkbTypes::MultiPolygon:
236
- return std::unique_ptr<QgsAbstractGeometry>( new QgsMultiPolygonV2 () );
236
+ return qgis::make_unique< QgsMultiPolygonV2 >( );
237
237
case QgsWkbTypes::MultiPoint:
238
- return std::unique_ptr<QgsAbstractGeometry>( new QgsMultiPointV2 () );
238
+ return qgis::make_unique< QgsMultiPointV2 >( );
239
239
case QgsWkbTypes::MultiCurve:
240
- return std::unique_ptr<QgsAbstractGeometry>( new QgsMultiCurve () );
240
+ return qgis::make_unique< QgsMultiCurve >( );
241
241
case QgsWkbTypes::MultiSurface:
242
- return std::unique_ptr<QgsAbstractGeometry>( new QgsMultiSurface () );
242
+ return qgis::make_unique< QgsMultiSurface >( );
243
243
case QgsWkbTypes::GeometryCollection:
244
- return std::unique_ptr<QgsAbstractGeometry>( new QgsGeometryCollection () );
244
+ return qgis::make_unique< QgsGeometryCollection >( );
245
245
case QgsWkbTypes::Triangle:
246
- return std::unique_ptr<QgsAbstractGeometry>( new QgsTriangle () );
246
+ return qgis::make_unique< QgsTriangle >( );
247
247
default :
248
248
return nullptr ;
249
249
}
@@ -256,22 +256,22 @@ std::unique_ptr<QgsGeometryCollection> QgsGeometryFactory::createCollectionOfTyp
256
256
switch ( type )
257
257
{
258
258
case QgsWkbTypes::MultiPoint:
259
- collect. reset ( new QgsMultiPointV2 () );
259
+ collect = qgis::make_unique< QgsMultiPointV2 >( );
260
260
break ;
261
261
case QgsWkbTypes::MultiLineString:
262
- collect. reset ( new QgsMultiLineString () );
262
+ collect = qgis::make_unique< QgsMultiLineString >( );
263
263
break ;
264
264
case QgsWkbTypes::MultiCurve:
265
- collect. reset ( new QgsMultiCurve () );
265
+ collect = qgis::make_unique< QgsMultiCurve >( );
266
266
break ;
267
267
case QgsWkbTypes::MultiPolygon:
268
- collect. reset ( new QgsMultiPolygonV2 () );
268
+ collect = qgis::make_unique< QgsMultiPolygonV2 >( );
269
269
break ;
270
270
case QgsWkbTypes::MultiSurface:
271
- collect. reset ( new QgsMultiSurface () );
271
+ collect = qgis::make_unique< QgsMultiSurface >( );
272
272
break ;
273
273
case QgsWkbTypes::GeometryCollection:
274
- collect. reset ( new QgsGeometryCollection () );
274
+ collect = qgis::make_unique< QgsGeometryCollection >( );
275
275
break ;
276
276
default :
277
277
// should not be possible
0 commit comments