Skip to content

Commit 26a911c

Browse files
authoredAug 17, 2017
Merge pull request #4751 from nyalldawson/unique_ptr
Return std::unique_ptrs where possible
2 parents fad5973 + e0d1ddc commit 26a911c

14 files changed

+132
-131
lines changed
 

‎src/core/auth/qgsauthmanager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ bool QgsAuthManager::registerCoreAuthMethods()
782782
mAuthMethods.clear();
783783
Q_FOREACH ( const QString &authMethodKey, QgsAuthMethodRegistry::instance()->authMethodList() )
784784
{
785-
mAuthMethods.insert( authMethodKey, QgsAuthMethodRegistry::instance()->authMethod( authMethodKey ) );
785+
mAuthMethods.insert( authMethodKey, QgsAuthMethodRegistry::instance()->authMethod( authMethodKey ).release() );
786786
}
787787

788788
return !mAuthMethods.isEmpty();

‎src/core/auth/qgsauthmethodregistry.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void QgsAuthMethodRegistry::setLibraryDirectory( const QDir &path )
260260
// typedef for the QgsDataProvider class factory
261261
typedef QgsAuthMethod *classFactoryFunction_t();
262262

263-
QgsAuthMethod *QgsAuthMethodRegistry::authMethod( const QString &authMethodKey )
263+
std::unique_ptr<QgsAuthMethod> QgsAuthMethodRegistry::authMethod( const QString &authMethodKey )
264264
{
265265
// load the plugin
266266
QString lib = library( authMethodKey );
@@ -299,7 +299,7 @@ QgsAuthMethod *QgsAuthMethodRegistry::authMethod( const QString &authMethodKey )
299299
return nullptr;
300300
}
301301

302-
QgsAuthMethod *authMethod = classFactory();
302+
std::unique_ptr< QgsAuthMethod > authMethod( classFactory() );
303303
if ( !authMethod )
304304
{
305305
QgsMessageLog::logMessage( QObject::tr( "Unable to instantiate the auth method plugin %1" ).arg( lib ) );
@@ -342,19 +342,16 @@ QFunctionPointer QgsAuthMethodRegistry::function( QString const &authMethodKey,
342342
}
343343
}
344344

345-
QLibrary *QgsAuthMethodRegistry::authMethodLibrary( const QString &authMethodKey ) const
345+
std::unique_ptr<QLibrary> QgsAuthMethodRegistry::authMethodLibrary( const QString &authMethodKey ) const
346346
{
347-
QLibrary *myLib = new QLibrary( library( authMethodKey ) );
347+
std::unique_ptr< QLibrary > myLib( new QLibrary( library( authMethodKey ) ) );
348348

349349
QgsDebugMsg( "Library name is " + myLib->fileName() );
350350

351351
if ( myLib->load() )
352352
return myLib;
353353

354354
QgsDebugMsg( "Cannot load library: " + myLib->errorString() );
355-
356-
delete myLib;
357-
358355
return nullptr;
359356
}
360357

‎src/core/auth/qgsauthmethodregistry.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <QLibrary>
2424
#include <QMap>
2525
#include <QString>
26+
#include <memory>
2627

2728
#include "qgis_core.h"
2829

@@ -67,7 +68,7 @@ class CORE_EXPORT QgsAuthMethodRegistry
6768
\param authMethodKey identificator of the auth method
6869
\returns instance of auth method or nullptr on error
6970
*/
70-
QgsAuthMethod *authMethod( const QString &authMethodKey );
71+
std::unique_ptr< QgsAuthMethod > authMethod( const QString &authMethodKey );
7172

7273
/** Return the auth method capabilities
7374
\param authMethodKey identificator of the auth method
@@ -89,7 +90,7 @@ class CORE_EXPORT QgsAuthMethodRegistry
8990
const QString &functionName );
9091

9192
//! Return the library object associated with an auth method key
92-
QLibrary *authMethodLibrary( const QString &authMethodKey ) const;
93+
std::unique_ptr< QLibrary > authMethodLibrary( const QString &authMethodKey ) const;
9394

9495
//! Return list of available auth methods by their keys
9596
QStringList authMethodList() const;

‎src/core/geometry/qgsgeometry.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -134,70 +134,70 @@ bool QgsGeometry::isNull() const
134134

135135
QgsGeometry QgsGeometry::fromWkt( const QString &wkt )
136136
{
137-
QgsAbstractGeometry *geom = QgsGeometryFactory::geomFromWkt( wkt );
137+
std::unique_ptr< QgsAbstractGeometry > geom = QgsGeometryFactory::geomFromWkt( wkt );
138138
if ( !geom )
139139
{
140140
return QgsGeometry();
141141
}
142-
return QgsGeometry( geom );
142+
return QgsGeometry( geom.release() );
143143
}
144144

145145
QgsGeometry QgsGeometry::fromPoint( const QgsPointXY &point )
146146
{
147-
QgsAbstractGeometry *geom = QgsGeometryFactory::fromPoint( point );
147+
std::unique_ptr< QgsAbstractGeometry > geom( QgsGeometryFactory::fromPoint( point ) );
148148
if ( geom )
149149
{
150-
return QgsGeometry( geom );
150+
return QgsGeometry( geom.release() );
151151
}
152152
return QgsGeometry();
153153
}
154154

155155
QgsGeometry QgsGeometry::fromPolyline( const QgsPolyline &polyline )
156156
{
157-
QgsAbstractGeometry *geom = QgsGeometryFactory::fromPolyline( polyline );
157+
std::unique_ptr< QgsAbstractGeometry > geom = QgsGeometryFactory::fromPolyline( polyline );
158158
if ( geom )
159159
{
160-
return QgsGeometry( geom );
160+
return QgsGeometry( geom.release() );
161161
}
162162
return QgsGeometry();
163163
}
164164

165165
QgsGeometry QgsGeometry::fromPolygon( const QgsPolygon &polygon )
166166
{
167-
QgsAbstractGeometry *geom = QgsGeometryFactory::fromPolygon( polygon );
167+
std::unique_ptr< QgsPolygonV2 > geom = QgsGeometryFactory::fromPolygon( polygon );
168168
if ( geom )
169169
{
170-
return QgsGeometry( geom );
170+
return QgsGeometry( geom.release() );
171171
}
172172
return QgsGeometry();
173173
}
174174

175175
QgsGeometry QgsGeometry::fromMultiPoint( const QgsMultiPoint &multipoint )
176176
{
177-
QgsAbstractGeometry *geom = QgsGeometryFactory::fromMultiPoint( multipoint );
177+
std::unique_ptr< QgsMultiPointV2 > geom = QgsGeometryFactory::fromMultiPoint( multipoint );
178178
if ( geom )
179179
{
180-
return QgsGeometry( geom );
180+
return QgsGeometry( geom.release() );
181181
}
182182
return QgsGeometry();
183183
}
184184

185185
QgsGeometry QgsGeometry::fromMultiPolyline( const QgsMultiPolyline &multiline )
186186
{
187-
QgsAbstractGeometry *geom = QgsGeometryFactory::fromMultiPolyline( multiline );
187+
std::unique_ptr< QgsMultiLineString > geom = QgsGeometryFactory::fromMultiPolyline( multiline );
188188
if ( geom )
189189
{
190-
return QgsGeometry( geom );
190+
return QgsGeometry( geom.release() );
191191
}
192192
return QgsGeometry();
193193
}
194194

195195
QgsGeometry QgsGeometry::fromMultiPolygon( const QgsMultiPolygon &multipoly )
196196
{
197-
QgsAbstractGeometry *geom = QgsGeometryFactory::fromMultiPolygon( multipoly );
197+
std::unique_ptr< QgsMultiPolygonV2 > geom = QgsGeometryFactory::fromMultiPolygon( multipoly );
198198
if ( geom )
199199
{
200-
return QgsGeometry( geom );
200+
return QgsGeometry( geom.release() );
201201
}
202202
return QgsGeometry();
203203
}
@@ -246,7 +246,7 @@ void QgsGeometry::fromWkb( unsigned char *wkb, int length )
246246
delete d->geometry;
247247
}
248248
QgsConstWkbPtr ptr( wkb, length );
249-
d->geometry = QgsGeometryFactory::geomFromWkb( ptr );
249+
d->geometry = QgsGeometryFactory::geomFromWkb( ptr ).release();
250250
delete [] wkb;
251251
}
252252

@@ -259,7 +259,7 @@ void QgsGeometry::fromWkb( const QByteArray &wkb )
259259
delete d->geometry;
260260
}
261261
QgsConstWkbPtr ptr( wkb );
262-
d->geometry = QgsGeometryFactory::geomFromWkb( ptr );
262+
d->geometry = QgsGeometryFactory::geomFromWkb( ptr ).release();
263263
}
264264

265265
GEOSGeometry *QgsGeometry::exportToGeos( double precision ) const
@@ -1155,16 +1155,16 @@ bool QgsGeometry::convertToMultiType()
11551155
return true;
11561156
}
11571157

1158-
QgsGeometryCollection *multiGeom = qgsgeometry_cast<QgsGeometryCollection *>
1159-
( QgsGeometryFactory::geomFromWkbType( QgsWkbTypes::multiType( d->geometry->wkbType() ) ) );
1158+
std::unique_ptr< QgsAbstractGeometry >geom = QgsGeometryFactory::geomFromWkbType( QgsWkbTypes::multiType( d->geometry->wkbType() ) );
1159+
QgsGeometryCollection *multiGeom = qgsgeometry_cast<QgsGeometryCollection *>( geom.get() );
11601160
if ( !multiGeom )
11611161
{
11621162
return false;
11631163
}
11641164

11651165
detach( true );
11661166
multiGeom->addGeometry( d->geometry );
1167-
d->geometry = multiGeom;
1167+
d->geometry = geom.release();
11681168
return true;
11691169
}
11701170

@@ -2026,11 +2026,11 @@ int QgsGeometry::avoidIntersections( const QList<QgsVectorLayer *> &avoidInterse
20262026
return 1;
20272027
}
20282028

2029-
QgsAbstractGeometry *diffGeom = QgsGeometryEditUtils::avoidIntersections( *( d->geometry ), avoidIntersectionsLayers, ignoreFeatures );
2029+
std::unique_ptr< QgsAbstractGeometry > diffGeom = QgsGeometryEditUtils::avoidIntersections( *( d->geometry ), avoidIntersectionsLayers, ignoreFeatures );
20302030
if ( diffGeom )
20312031
{
20322032
detach( false );
2033-
d->geometry = diffGeom;
2033+
d->geometry = diffGeom.release();
20342034
}
20352035
return 0;
20362036
}

‎src/core/geometry/qgsgeometrycollection.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ bool QgsGeometryCollection::fromWkb( QgsConstWkbPtr &wkbPtr )
219219
mGeometries.clear();
220220
for ( int i = 0; i < nGeometries; ++i )
221221
{
222-
QgsAbstractGeometry *geom = QgsGeometryFactory::geomFromWkb( wkbPtr ); // also updates wkbPtr
222+
std::unique_ptr< QgsAbstractGeometry > geom( QgsGeometryFactory::geomFromWkb( wkbPtr ) ); // also updates wkbPtr
223223
if ( geom )
224224
{
225-
if ( !addGeometry( geom ) )
225+
if ( !addGeometry( geom.release() ) )
226226
{
227227
qDeleteAll( mGeometries );
228228
mGeometries = geometryListBackup;
@@ -597,11 +597,10 @@ bool QgsGeometryCollection::hasCurvedSegments() const
597597

598598
QgsAbstractGeometry *QgsGeometryCollection::segmentize( double tolerance, SegmentationToleranceType toleranceType ) const
599599
{
600-
QgsAbstractGeometry *geom = QgsGeometryFactory::geomFromWkbType( mWkbType );
601-
QgsGeometryCollection *geomCollection = qgsgeometry_cast<QgsGeometryCollection *>( geom );
600+
std::unique_ptr< QgsAbstractGeometry > geom( QgsGeometryFactory::geomFromWkbType( mWkbType ) );
601+
QgsGeometryCollection *geomCollection = qgsgeometry_cast<QgsGeometryCollection *>( geom.get() );
602602
if ( !geomCollection )
603603
{
604-
delete geom;
605604
return clone();
606605
}
607606

@@ -610,7 +609,7 @@ QgsAbstractGeometry *QgsGeometryCollection::segmentize( double tolerance, Segmen
610609
{
611610
geomCollection->addGeometry( ( *geomIt )->segmentize( tolerance, toleranceType ) );
612611
}
613-
return geomCollection;
612+
return geom.release();
614613
}
615614

616615
double QgsGeometryCollection::vertexAngle( QgsVertexId vertex ) const

‎src/core/geometry/qgsgeometryeditutils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ bool QgsGeometryEditUtils::deletePart( QgsAbstractGeometry *geom, int partNum )
221221
return c->removeGeometry( partNum );
222222
}
223223

224-
QgsAbstractGeometry *QgsGeometryEditUtils::avoidIntersections( const QgsAbstractGeometry &geom,
224+
std::unique_ptr<QgsAbstractGeometry> QgsGeometryEditUtils::avoidIntersections( const QgsAbstractGeometry &geom,
225225
const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
226226
QHash<QgsVectorLayer *, QSet<QgsFeatureId> > ignoreFeatures )
227227
{
@@ -281,7 +281,7 @@ QgsAbstractGeometry *QgsGeometryEditUtils::avoidIntersections( const QgsAbstract
281281
return nullptr;
282282
}
283283

284-
QgsAbstractGeometry *diffGeom = geomEngine->difference( combinedGeometries );
284+
std::unique_ptr< QgsAbstractGeometry > diffGeom( geomEngine->difference( combinedGeometries ) );
285285

286286
delete combinedGeometries;
287287
return diffGeom;

‎src/core/geometry/qgsgeometryeditutils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class QgsVectorLayer;
2626
#include "qgsfeature.h"
2727
#include "qgsgeometry.h"
2828
#include <QMap>
29+
#include <memory>
2930

3031
/** \ingroup core
3132
* \class QgsGeometryEditUtils
@@ -69,7 +70,7 @@ class QgsGeometryEditUtils
6970
* \param avoidIntersectionsLayers list of layers to check for intersections
7071
* \param ignoreFeatures map of layer to feature id of features to ignore
7172
*/
72-
static QgsAbstractGeometry *avoidIntersections( const QgsAbstractGeometry &geom,
73+
static std::unique_ptr< QgsAbstractGeometry > avoidIntersections( const QgsAbstractGeometry &geom,
7374
const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
7475
QHash<QgsVectorLayer *, QSet<QgsFeatureId> > ignoreFeatures = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
7576
};

‎src/core/geometry/qgsgeometryfactory.cpp

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "qgswkbtypes.h"
3131
#include "qgslogger.h"
3232

33-
QgsAbstractGeometry *QgsGeometryFactory::geomFromWkb( QgsConstWkbPtr &wkbPtr )
33+
std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::geomFromWkb( QgsConstWkbPtr &wkbPtr )
3434
{
3535
if ( !wkbPtr )
3636
return nullptr;
@@ -49,9 +49,7 @@ QgsAbstractGeometry *QgsGeometryFactory::geomFromWkb( QgsConstWkbPtr &wkbPtr )
4949
}
5050
wkbPtr -= 1 + sizeof( int );
5151

52-
QgsAbstractGeometry *geom = nullptr;
53-
54-
geom = geomFromWkbType( type );
52+
std::unique_ptr< QgsAbstractGeometry > geom = geomFromWkbType( type );
5553

5654
if ( geom )
5755
{
@@ -63,86 +61,84 @@ QgsAbstractGeometry *QgsGeometryFactory::geomFromWkb( QgsConstWkbPtr &wkbPtr )
6361
{
6462
Q_UNUSED( e );
6563
QgsDebugMsg( "WKB exception: " + e.what() );
66-
delete geom;
67-
geom = nullptr;
64+
geom.reset();
6865
}
6966
}
7067

7168
return geom;
7269
}
7370

74-
QgsAbstractGeometry *QgsGeometryFactory::geomFromWkt( const QString &text )
71+
std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::geomFromWkt( const QString &text )
7572
{
7673
QString trimmed = text.trimmed();
77-
QgsAbstractGeometry *geom = nullptr;
74+
std::unique_ptr< QgsAbstractGeometry> geom;
7875
if ( trimmed.startsWith( QLatin1String( "Point" ), Qt::CaseInsensitive ) )
7976
{
80-
geom = new QgsPoint();
77+
geom.reset( new QgsPoint() );
8178
}
8279
else if ( trimmed.startsWith( QLatin1String( "LineString" ), Qt::CaseInsensitive ) )
8380
{
84-
geom = new QgsLineString();
81+
geom.reset( new QgsLineString() );
8582
}
8683
else if ( trimmed.startsWith( QLatin1String( "CircularString" ), Qt::CaseInsensitive ) )
8784
{
88-
geom = new QgsCircularString();
85+
geom.reset( new QgsCircularString() );
8986
}
9087
else if ( trimmed.startsWith( QLatin1String( "CompoundCurve" ), Qt::CaseInsensitive ) )
9188
{
92-
geom = new QgsCompoundCurve();
89+
geom.reset( new QgsCompoundCurve() );
9390
}
9491
else if ( trimmed.startsWith( QLatin1String( "Polygon" ), Qt::CaseInsensitive ) )
9592
{
96-
geom = new QgsPolygonV2();
93+
geom.reset( new QgsPolygonV2() );
9794
}
9895
else if ( trimmed.startsWith( QLatin1String( "CurvePolygon" ), Qt::CaseInsensitive ) )
9996
{
100-
geom = new QgsCurvePolygon();
97+
geom.reset( new QgsCurvePolygon() );
10198
}
10299
else if ( trimmed.startsWith( QLatin1String( "MultiPoint" ), Qt::CaseInsensitive ) )
103100
{
104-
geom = new QgsMultiPointV2();
101+
geom.reset( new QgsMultiPointV2() );
105102
}
106103
else if ( trimmed.startsWith( QLatin1String( "MultiCurve" ), Qt::CaseInsensitive ) )
107104
{
108-
geom = new QgsMultiCurve();
105+
geom.reset( new QgsMultiCurve() );
109106
}
110107
else if ( trimmed.startsWith( QLatin1String( "MultiLineString" ), Qt::CaseInsensitive ) )
111108
{
112-
geom = new QgsMultiLineString();
109+
geom.reset( new QgsMultiLineString() );
113110
}
114111
else if ( trimmed.startsWith( QLatin1String( "MultiSurface" ), Qt::CaseInsensitive ) )
115112
{
116-
geom = new QgsMultiSurface();
113+
geom.reset( new QgsMultiSurface() );
117114
}
118115
else if ( trimmed.startsWith( QLatin1String( "MultiPolygon" ), Qt::CaseInsensitive ) )
119116
{
120-
geom = new QgsMultiPolygonV2();
117+
geom.reset( new QgsMultiPolygonV2() );
121118
}
122119
else if ( trimmed.startsWith( QLatin1String( "GeometryCollection" ), Qt::CaseInsensitive ) )
123120
{
124-
geom = new QgsGeometryCollection();
121+
geom.reset( new QgsGeometryCollection() );
125122
}
126123

127124
if ( geom )
128125
{
129126
if ( !geom->fromWkt( text ) )
130127
{
131-
delete geom;
132128
return nullptr;
133129
}
134130
}
135131
return geom;
136132
}
137133

138-
QgsAbstractGeometry *QgsGeometryFactory::fromPoint( const QgsPointXY &point )
134+
std::unique_ptr< QgsAbstractGeometry > QgsGeometryFactory::fromPoint( const QgsPointXY &point )
139135
{
140-
return new QgsPoint( point.x(), point.y() );
136+
return std::unique_ptr< QgsAbstractGeometry >( new QgsPoint( point.x(), point.y() ) );
141137
}
142138

143-
QgsAbstractGeometry *QgsGeometryFactory::fromMultiPoint( const QgsMultiPoint &multipoint )
139+
std::unique_ptr<QgsMultiPointV2> QgsGeometryFactory::fromMultiPoint( const QgsMultiPoint &multipoint )
144140
{
145-
QgsMultiPointV2 *mp = new QgsMultiPointV2();
141+
std::unique_ptr< QgsMultiPointV2 > mp( new QgsMultiPointV2() );
146142
QgsMultiPoint::const_iterator ptIt = multipoint.constBegin();
147143
for ( ; ptIt != multipoint.constEnd(); ++ptIt )
148144
{
@@ -152,55 +148,55 @@ QgsAbstractGeometry *QgsGeometryFactory::fromMultiPoint( const QgsMultiPoint &mu
152148
return mp;
153149
}
154150

155-
QgsAbstractGeometry *QgsGeometryFactory::fromPolyline( const QgsPolyline &polyline )
151+
std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::fromPolyline( const QgsPolyline &polyline )
156152
{
157153
return linestringFromPolyline( polyline );
158154
}
159155

160-
QgsAbstractGeometry *QgsGeometryFactory::fromMultiPolyline( const QgsMultiPolyline &multiline )
156+
std::unique_ptr<QgsMultiLineString> QgsGeometryFactory::fromMultiPolyline( const QgsMultiPolyline &multiline )
161157
{
162-
QgsMultiLineString *mLine = new QgsMultiLineString();
158+
std::unique_ptr< QgsMultiLineString > mLine( new QgsMultiLineString() );
163159
for ( int i = 0; i < multiline.size(); ++i )
164160
{
165-
mLine->addGeometry( fromPolyline( multiline.at( i ) ) );
161+
mLine->addGeometry( fromPolyline( multiline.at( i ) ).release() );
166162
}
167163
return mLine;
168164
}
169165

170-
QgsAbstractGeometry *QgsGeometryFactory::fromPolygon( const QgsPolygon &polygon )
166+
std::unique_ptr<QgsPolygonV2> QgsGeometryFactory::fromPolygon( const QgsPolygon &polygon )
171167
{
172-
QgsPolygonV2 *poly = new QgsPolygonV2();
168+
std::unique_ptr< QgsPolygonV2 > poly( new QgsPolygonV2() );
173169

174170
QList<QgsCurve *> holes;
175171
for ( int i = 0; i < polygon.size(); ++i )
176172
{
177-
QgsLineString *l = linestringFromPolyline( polygon.at( i ) );
173+
std::unique_ptr< QgsLineString > l = linestringFromPolyline( polygon.at( i ) );
178174
l->close();
179175

180176
if ( i == 0 )
181177
{
182-
poly->setExteriorRing( l );
178+
poly->setExteriorRing( l.release() );
183179
}
184180
else
185181
{
186-
holes.push_back( l );
182+
holes.push_back( l.release() );
187183
}
188184
}
189185
poly->setInteriorRings( holes );
190186
return poly;
191187
}
192188

193-
QgsAbstractGeometry *QgsGeometryFactory::fromMultiPolygon( const QgsMultiPolygon &multipoly )
189+
std::unique_ptr< QgsMultiPolygonV2 > QgsGeometryFactory::fromMultiPolygon( const QgsMultiPolygon &multipoly )
194190
{
195-
QgsMultiPolygonV2 *mp = new QgsMultiPolygonV2();
191+
std::unique_ptr< QgsMultiPolygonV2 > mp( new QgsMultiPolygonV2() );
196192
for ( int i = 0; i < multipoly.size(); ++i )
197193
{
198-
mp->addGeometry( fromPolygon( multipoly.at( i ) ) );
194+
mp->addGeometry( fromPolygon( multipoly.at( i ) ).release() );
199195
}
200196
return mp;
201197
}
202198

203-
QgsAbstractGeometry *QgsGeometryFactory::fromRect( const QgsRectangle &rect )
199+
std::unique_ptr<QgsPolygonV2> QgsGeometryFactory::fromRect( const QgsRectangle &rect )
204200
{
205201
QgsPolyline ring;
206202
ring.append( QgsPointXY( rect.xMinimum(), rect.yMinimum() ) );
@@ -215,7 +211,7 @@ QgsAbstractGeometry *QgsGeometryFactory::fromRect( const QgsRectangle &rect )
215211
return fromPolygon( polygon );
216212
}
217213

218-
QgsLineString *QgsGeometryFactory::linestringFromPolyline( const QgsPolyline &polyline )
214+
std::unique_ptr<QgsLineString> QgsGeometryFactory::linestringFromPolyline( const QgsPolyline &polyline )
219215
{
220216
QVector< double > x;
221217
x.reserve( polyline.size() );
@@ -227,39 +223,39 @@ QgsLineString *QgsGeometryFactory::linestringFromPolyline( const QgsPolyline &po
227223
x << it->x();
228224
y << it->y();
229225
}
230-
QgsLineString *line = new QgsLineString( x, y );
226+
std::unique_ptr< QgsLineString > line( new QgsLineString( x, y ) );
231227
return line;
232228
}
233229

234-
QgsAbstractGeometry *QgsGeometryFactory::geomFromWkbType( QgsWkbTypes::Type t )
230+
std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::geomFromWkbType( QgsWkbTypes::Type t )
235231
{
236232
QgsWkbTypes::Type type = QgsWkbTypes::flatType( t );
237233
switch ( type )
238234
{
239235
case QgsWkbTypes::Point:
240-
return new QgsPoint();
236+
return std::unique_ptr<QgsAbstractGeometry>( new QgsPoint() );
241237
case QgsWkbTypes::LineString:
242-
return new QgsLineString();
238+
return std::unique_ptr<QgsAbstractGeometry>( new QgsLineString() );
243239
case QgsWkbTypes::CircularString:
244-
return new QgsCircularString();
240+
return std::unique_ptr<QgsAbstractGeometry>( new QgsCircularString() );
245241
case QgsWkbTypes::CompoundCurve:
246-
return new QgsCompoundCurve();
242+
return std::unique_ptr<QgsAbstractGeometry>( new QgsCompoundCurve() );
247243
case QgsWkbTypes::Polygon:
248-
return new QgsPolygonV2();
244+
return std::unique_ptr<QgsAbstractGeometry>( new QgsPolygonV2() );
249245
case QgsWkbTypes::CurvePolygon:
250-
return new QgsCurvePolygon();
246+
return std::unique_ptr<QgsAbstractGeometry>( new QgsCurvePolygon() );
251247
case QgsWkbTypes::MultiLineString:
252-
return new QgsMultiLineString();
248+
return std::unique_ptr<QgsAbstractGeometry>( new QgsMultiLineString() );
253249
case QgsWkbTypes::MultiPolygon:
254-
return new QgsMultiPolygonV2();
250+
return std::unique_ptr<QgsAbstractGeometry>( new QgsMultiPolygonV2() );
255251
case QgsWkbTypes::MultiPoint:
256-
return new QgsMultiPointV2();
252+
return std::unique_ptr<QgsAbstractGeometry>( new QgsMultiPointV2() );
257253
case QgsWkbTypes::MultiCurve:
258-
return new QgsMultiCurve();
254+
return std::unique_ptr<QgsAbstractGeometry>( new QgsMultiCurve() );
259255
case QgsWkbTypes::MultiSurface:
260-
return new QgsMultiSurface();
256+
return std::unique_ptr<QgsAbstractGeometry>( new QgsMultiSurface() );
261257
case QgsWkbTypes::GeometryCollection:
262-
return new QgsGeometryCollection();
258+
return std::unique_ptr<QgsAbstractGeometry>( new QgsGeometryCollection() );
263259
default:
264260
return nullptr;
265261
}

‎src/core/geometry/qgsgeometryfactory.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class QgsLineString;
2929
class QgsConstWkbPtr;
3030
class QgsRectangle;
3131
class QgsGeometryCollection;
32+
class QgsMultiPointV2;
33+
class QgsMultiLineString;
34+
class QgsPolygonV2;
35+
class QgsMultiPolygonV2;
3236

3337
//compatibility with old classes
3438
#include "qgspointxy.h"
@@ -51,28 +55,28 @@ class CORE_EXPORT QgsGeometryFactory
5155
/** Construct geometry from a WKB string.
5256
* Updates position of the passed WKB pointer.
5357
*/
54-
static QgsAbstractGeometry *geomFromWkb( QgsConstWkbPtr &wkb );
58+
static std::unique_ptr< QgsAbstractGeometry > geomFromWkb( QgsConstWkbPtr &wkb );
5559

5660
/** Construct geometry from a WKT string.
5761
*/
58-
static QgsAbstractGeometry *geomFromWkt( const QString &text );
62+
static std::unique_ptr< QgsAbstractGeometry > geomFromWkt( const QString &text );
5963

6064
//! Construct geometry from a point
61-
static QgsAbstractGeometry *fromPoint( const QgsPointXY &point );
65+
static std::unique_ptr< QgsAbstractGeometry > fromPoint( const QgsPointXY &point );
6266
//! Construct geometry from a multipoint
63-
static QgsAbstractGeometry *fromMultiPoint( const QgsMultiPoint &multipoint );
67+
static std::unique_ptr<QgsMultiPointV2> fromMultiPoint( const QgsMultiPoint &multipoint );
6468
//! Construct geometry from a polyline
65-
static QgsAbstractGeometry *fromPolyline( const QgsPolyline &polyline );
69+
static std::unique_ptr< QgsAbstractGeometry > fromPolyline( const QgsPolyline &polyline );
6670
//! Construct geometry from a multipolyline
67-
static QgsAbstractGeometry *fromMultiPolyline( const QgsMultiPolyline &multiline );
71+
static std::unique_ptr<QgsMultiLineString> fromMultiPolyline( const QgsMultiPolyline &multiline );
6872
//! Construct geometry from a polygon
69-
static QgsAbstractGeometry *fromPolygon( const QgsPolygon &polygon );
73+
static std::unique_ptr<QgsPolygonV2> fromPolygon( const QgsPolygon &polygon );
7074
//! Construct geometry from a multipolygon
71-
static QgsAbstractGeometry *fromMultiPolygon( const QgsMultiPolygon &multipoly );
75+
static std::unique_ptr<QgsMultiPolygonV2> fromMultiPolygon( const QgsMultiPolygon &multipoly );
7276
//! Construct geometry from a rectangle
73-
static QgsAbstractGeometry *fromRect( const QgsRectangle &rect );
77+
static std::unique_ptr<QgsPolygonV2> fromRect( const QgsRectangle &rect );
7478
//! Return empty geometry from wkb type
75-
static QgsAbstractGeometry *geomFromWkbType( QgsWkbTypes::Type t );
79+
static std::unique_ptr< QgsAbstractGeometry > geomFromWkbType( QgsWkbTypes::Type t );
7680

7781
/**
7882
* Returns a new geometry collection matching a specified WKB \a type. For instance, if
@@ -81,7 +85,7 @@ class CORE_EXPORT QgsGeometryFactory
8185
static std::unique_ptr< QgsGeometryCollection > createCollectionOfType( QgsWkbTypes::Type type );
8286

8387
private:
84-
static QgsLineString *linestringFromPolyline( const QgsPolyline &polyline );
88+
static std::unique_ptr< QgsLineString > linestringFromPolyline( const QgsPolyline &polyline );
8589
};
8690

8791
#endif // QGSGEOMETRYFACTORY_H

‎src/core/qgstestutils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,9 @@
5555
QGSCOMPARENEAR( rectangle1.yMaximum(), rectangle2.yMaximum(), epsilon ); \
5656
}
5757

58+
//sometimes GML attributes are in a different order - but that's ok
59+
#define QGSCOMPAREGML(result,expected) { \
60+
QCOMPARE( result.replace( QStringLiteral("ts=\" \" cs=\",\""), QStringLiteral("cs=\",\" ts=\" \"") ), expected ); \
61+
}
62+
5863
#endif // QGSTESTUTILS_H

‎src/core/qgsvectordataprovider.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ QgsGeometry QgsVectorDataProvider::convertToProviderType( const QgsGeometry &geo
722722
return QgsGeometry();
723723
}
724724

725-
QgsAbstractGeometry *outputGeom = nullptr;
725+
std::unique_ptr< QgsAbstractGeometry > outputGeom;
726726

727727
//convert compoundcurve to circularstring (possible if compoundcurve consists of one circular string)
728728
if ( QgsWkbTypes::flatType( providerGeomType ) == QgsWkbTypes::CircularString )
@@ -735,7 +735,7 @@ QgsGeometry QgsVectorDataProvider::convertToProviderType( const QgsGeometry &geo
735735
const QgsCircularString *circularString = qgsgeometry_cast<const QgsCircularString *>( compoundCurve->curveAt( 0 ) );
736736
if ( circularString )
737737
{
738-
outputGeom = circularString->clone();
738+
outputGeom.reset( circularString->clone() );
739739
}
740740
}
741741
}
@@ -745,7 +745,7 @@ QgsGeometry QgsVectorDataProvider::convertToProviderType( const QgsGeometry &geo
745745
if ( QgsWkbTypes::isMultiType( providerGeomType ) && !QgsWkbTypes::isMultiType( geometry->wkbType() ) )
746746
{
747747
outputGeom = QgsGeometryFactory::geomFromWkbType( providerGeomType );
748-
QgsGeometryCollection *geomCollection = qgsgeometry_cast<QgsGeometryCollection *>( outputGeom );
748+
QgsGeometryCollection *geomCollection = qgsgeometry_cast<QgsGeometryCollection *>( outputGeom.get() );
749749
if ( geomCollection )
750750
{
751751
geomCollection->addGeometry( geometry->clone() );
@@ -758,8 +758,7 @@ QgsGeometry QgsVectorDataProvider::convertToProviderType( const QgsGeometry &geo
758758
QgsAbstractGeometry *curveGeom = outputGeom ? outputGeom->toCurveType() : geometry->toCurveType();
759759
if ( curveGeom )
760760
{
761-
delete outputGeom;
762-
outputGeom = curveGeom;
761+
outputGeom.reset( curveGeom );
763762
}
764763
}
765764

@@ -770,8 +769,7 @@ QgsGeometry QgsVectorDataProvider::convertToProviderType( const QgsGeometry &geo
770769
segmentizedGeom = outputGeom ? outputGeom->segmentize() : geometry->segmentize();
771770
if ( segmentizedGeom )
772771
{
773-
delete outputGeom;
774-
outputGeom = segmentizedGeom;
772+
outputGeom.reset( segmentizedGeom );
775773
}
776774
}
777775

@@ -780,22 +778,22 @@ QgsGeometry QgsVectorDataProvider::convertToProviderType( const QgsGeometry &geo
780778
{
781779
if ( !outputGeom )
782780
{
783-
outputGeom = geometry->clone();
781+
outputGeom.reset( geometry->clone() );
784782
}
785783
outputGeom->addZValue();
786784
}
787785
if ( QgsWkbTypes::hasM( providerGeomType ) )
788786
{
789787
if ( !outputGeom )
790788
{
791-
outputGeom = geometry->clone();
789+
outputGeom.reset( geometry->clone() );
792790
}
793791
outputGeom->addMValue();
794792
}
795793

796794
if ( outputGeom )
797795
{
798-
return QgsGeometry( outputGeom );
796+
return QgsGeometry( outputGeom.release() );
799797
}
800798
return QgsGeometry();
801799
}

‎src/ui/qgsdiagrampropertiesbase.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@
16171617
<property name="syncGroup" stdset="0">
16181618
<string notr="true">labelplacementgroup</string>
16191619
</property>
1620-
<layout class="QHBoxLayout" name="horizontalLayout_9">
1620+
<layout class="QHBoxLayout" name="horizontalLayout_92">
16211621
<property name="leftMargin">
16221622
<number>8</number>
16231623
</property>

‎tests/src/core/testqgsdistancearea.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void TestQgsDistanceArea::regression13601()
218218
QgsDistanceArea calc;
219219
calc.setEllipsoid( QStringLiteral( "NONE" ) );
220220
calc.setSourceCrs( QgsCoordinateReferenceSystem::fromSrsId( 1108L ) );
221-
QgsGeometry geom( QgsGeometryFactory::geomFromWkt( QStringLiteral( "Polygon ((252000 1389000, 265000 1389000, 265000 1385000, 252000 1385000, 252000 1389000))" ) ) );
221+
QgsGeometry geom( QgsGeometryFactory::geomFromWkt( QStringLiteral( "Polygon ((252000 1389000, 265000 1389000, 265000 1385000, 252000 1385000, 252000 1389000))" ) ).release() );
222222
QGSCOMPARENEAR( calc.measureArea( geom ), 52000000, 0.0001 );
223223
}
224224

@@ -230,21 +230,21 @@ void TestQgsDistanceArea::collections()
230230
myDa.setEllipsoid( QStringLiteral( "WGS84" ) );
231231

232232
//collection of lines, should be sum of line length
233-
QgsGeometry lines( QgsGeometryFactory::geomFromWkt( QStringLiteral( "GeometryCollection( LineString(0 36.53, 5.76 -48.16), LineString(0 25.54, 24.20 36.70) )" ) ) );
233+
QgsGeometry lines( QgsGeometryFactory::geomFromWkt( QStringLiteral( "GeometryCollection( LineString(0 36.53, 5.76 -48.16), LineString(0 25.54, 24.20 36.70) )" ) ).release() );
234234
double result = myDa.measureLength( lines );
235235
QGSCOMPARENEAR( result, 12006159, 1 );
236236
result = myDa.measureArea( lines );
237237
QVERIFY( qgsDoubleNear( result, 0 ) );
238238

239239
//collection of polygons
240-
QgsGeometry polys( QgsGeometryFactory::geomFromWkt( QStringLiteral( "GeometryCollection( Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53)), Polygon((10 20, 15 20, 15 10, 10 20)) )" ) ) );
240+
QgsGeometry polys( QgsGeometryFactory::geomFromWkt( QStringLiteral( "GeometryCollection( Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53)), Polygon((10 20, 15 20, 15 10, 10 20)) )" ) ).release() );
241241
result = myDa.measureArea( polys );
242242
QGSCOMPARENEAR( result, 670434859475LL, 1 );
243243
result = myDa.measureLength( polys );
244244
QVERIFY( qgsDoubleNear( result, 0 ) );
245245

246246
//mixed collection
247-
QgsGeometry mixed( QgsGeometryFactory::geomFromWkt( QStringLiteral( "GeometryCollection( LineString(0 36.53, 5.76 -48.16), LineString(0 25.54, 24.20 36.70), Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53)), Polygon((10 20, 15 20, 15 10, 10 20)) )" ) ) );
247+
QgsGeometry mixed( QgsGeometryFactory::geomFromWkt( QStringLiteral( "GeometryCollection( LineString(0 36.53, 5.76 -48.16), LineString(0 25.54, 24.20 36.70), Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53)), Polygon((10 20, 15 20, 15 10, 10 20)) )" ) ).release() );
248248
//measure area specifically
249249
result = myDa.measureArea( mixed );
250250
QGSCOMPARENEAR( result, 670434859475LL, 1 );
@@ -375,7 +375,7 @@ void TestQgsDistanceArea::regression14675()
375375
QgsDistanceArea calc;
376376
calc.setEllipsoid( QStringLiteral( "GRS80" ) );
377377
calc.setSourceCrs( QgsCoordinateReferenceSystem::fromSrsId( 145L ) );
378-
QgsGeometry geom( QgsGeometryFactory::geomFromWkt( QStringLiteral( "Polygon ((917593.5791854317067191 6833700.00807378999888897, 917596.43389983859378844 6833700.67099479306489229, 917599.53056440979707986 6833700.78673478215932846, 917593.5791854317067191 6833700.00807378999888897))" ) ) );
378+
QgsGeometry geom( QgsGeometryFactory::geomFromWkt( QStringLiteral( "Polygon ((917593.5791854317067191 6833700.00807378999888897, 917596.43389983859378844 6833700.67099479306489229, 917599.53056440979707986 6833700.78673478215932846, 917593.5791854317067191 6833700.00807378999888897))" ) ).release() );
379379
//lots of tolerance here - the formulas get quite unstable with small areas due to division by very small floats
380380
QGSCOMPARENEAR( calc.measureArea( geom ), 0.833010, 0.03 );
381381
}
@@ -385,7 +385,7 @@ void TestQgsDistanceArea::regression16820()
385385
QgsDistanceArea calc;
386386
calc.setEllipsoid( QStringLiteral( "WGS84" ) );
387387
calc.setSourceCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:32634" ) ) );
388-
QgsGeometry geom( QgsGeometryFactory::geomFromWkt( QStringLiteral( "Polygon ((110250.54038314701756462 5084495.57398066483438015, 110243.46975068224128336 5084507.17200060561299324, 110251.23908144699817058 5084506.68309532757848501, 110251.2394439501222223 5084506.68307251576334238, 110250.54048078990308568 5084495.57553235255181789, 110250.54038314701756462 5084495.57398066483438015))" ) ) );
388+
QgsGeometry geom( QgsGeometryFactory::geomFromWkt( QStringLiteral( "Polygon ((110250.54038314701756462 5084495.57398066483438015, 110243.46975068224128336 5084507.17200060561299324, 110251.23908144699817058 5084506.68309532757848501, 110251.2394439501222223 5084506.68307251576334238, 110250.54048078990308568 5084495.57553235255181789, 110250.54038314701756462 5084495.57398066483438015))" ) ).release() );
389389
//lots of tolerance here - the formulas get quite unstable with small areas due to division by very small floats
390390
QGSCOMPARENEAR( calc.measureArea( geom ), 43.3280029296875, 0.2 );
391391
}

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,9 @@ void TestQgsGeometry::point()
617617
QgsPoint exportPointFloat( 1 / 3.0, 2 / 3.0 );
618618
QDomDocument doc( QStringLiteral( "gml" ) );
619619
QString expectedGML2( QStringLiteral( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">1,2</coordinates></Point>" ) );
620-
QCOMPARE( elemToString( exportPoint.asGML2( doc ) ), expectedGML2 );
620+
QGSCOMPAREGML( elemToString( exportPoint.asGML2( doc ) ), expectedGML2 );
621621
QString expectedGML2prec3( QStringLiteral( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.333,0.667</coordinates></Point>" ) );
622-
QCOMPARE( elemToString( exportPointFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
622+
QGSCOMPAREGML( elemToString( exportPointFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
623623

624624
//asGML3
625625
QString expectedGML3( QStringLiteral( "<Point xmlns=\"gml\"><pos xmlns=\"gml\" srsDimension=\"2\">1 2</pos></Point>" ) );
@@ -1739,9 +1739,9 @@ void TestQgsGeometry::lineString()
17391739
<< QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) );
17401740
QDomDocument doc( QStringLiteral( "gml" ) );
17411741
QString expectedGML2( QStringLiteral( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">31,32 41,42 51,52</coordinates></LineString>" ) );
1742-
QCOMPARE( elemToString( exportLine.asGML2( doc ) ), expectedGML2 );
1742+
QGSCOMPAREGML( elemToString( exportLine.asGML2( doc ) ), expectedGML2 );
17431743
QString expectedGML2prec3( QStringLiteral( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.333,0.667 1.333,1.667 2.333,2.667</coordinates></LineString>" ) );
1744-
QCOMPARE( elemToString( exportLineFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
1744+
QGSCOMPAREGML( elemToString( exportLineFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
17451745

17461746
//asGML3
17471747
QString expectedGML3( QStringLiteral( "<LineString xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">31 32 41 42 51 52</posList></LineString>" ) );
@@ -3203,7 +3203,7 @@ void TestQgsGeometry::polygon()
32033203

32043204
// as GML2
32053205
QString expectedSimpleGML2( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></outerBoundaryIs></Polygon>" ) );
3206-
QCOMPARE( elemToString( exportPolygon.asGML2( doc ) ), expectedSimpleGML2 );
3206+
QGSCOMPAREGML( elemToString( exportPolygon.asGML2( doc ) ), expectedSimpleGML2 );
32073207

32083208
//as GML3
32093209
QString expectedSimpleGML3( QStringLiteral( "<Polygon xmlns=\"gml\"><exterior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">0 0 0 10 10 10 10 0 0 0</posList></LinearRing></exterior></Polygon>" ) );
@@ -3240,10 +3240,10 @@ void TestQgsGeometry::polygon()
32403240
// as GML2
32413241
QString expectedGML2( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></outerBoundaryIs>" ) );
32423242
expectedGML2 += QStringLiteral( "<innerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">1,1 1,9 9,9 9,1 1,1</coordinates></LinearRing></innerBoundaryIs></Polygon>" );
3243-
QCOMPARE( elemToString( exportPolygon.asGML2( doc ) ), expectedGML2 );
3243+
QGSCOMPAREGML( elemToString( exportPolygon.asGML2( doc ) ), expectedGML2 );
32443244
QString expectedGML2prec3( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">1.111,1.111 1.111,11.111 11.111,11.111 11.111,1.111 1.111,1.111</coordinates></LinearRing></outerBoundaryIs>" ) );
32453245
expectedGML2prec3 += QStringLiteral( "<innerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.667,0.667 0.667,1.333 1.333,1.333 1.333,0.667 0.667,0.667</coordinates></LinearRing></innerBoundaryIs></Polygon>" );
3246-
QCOMPARE( elemToString( exportPolygonFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
3246+
QGSCOMPAREGML( elemToString( exportPolygonFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
32473247

32483248
//as GML3
32493249
QString expectedGML3( QStringLiteral( "<Polygon xmlns=\"gml\"><exterior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">0 0 0 10 10 10 10 0 0 0</posList></LinearRing></exterior>" ) );
@@ -5293,7 +5293,7 @@ void TestQgsGeometry::wkbInOut()
52935293
void TestQgsGeometry::segmentizeCircularString()
52945294
{
52955295
QString wkt( QStringLiteral( "CIRCULARSTRING( 0 0, 0.5 0.5, 2 0 )" ) );
5296-
QgsCircularString *circularString = dynamic_cast<QgsCircularString *>( QgsGeometryFactory::geomFromWkt( wkt ) );
5296+
QgsCircularString *circularString = dynamic_cast<QgsCircularString *>( QgsGeometryFactory::geomFromWkt( wkt ).release() );
52975297
QVERIFY( circularString );
52985298
QgsLineString *lineString = circularString->curveToLine();
52995299
QVERIFY( lineString );
@@ -5311,11 +5311,11 @@ void TestQgsGeometry::directionNeutralSegmentation()
53115311
{
53125312
//Tests, if segmentation of a circularstring is the same in both directions
53135313
QString CWCircularStringWkt( QStringLiteral( "CIRCULARSTRING( 0 0, 0.5 0.5, 0.83 7.33 )" ) );
5314-
QgsCircularString *CWCircularString = static_cast<QgsCircularString *>( QgsGeometryFactory::geomFromWkt( CWCircularStringWkt ) );
5314+
QgsCircularString *CWCircularString = static_cast<QgsCircularString *>( QgsGeometryFactory::geomFromWkt( CWCircularStringWkt ).release() );
53155315
QgsLineString *CWLineString = CWCircularString->curveToLine();
53165316

53175317
QString CCWCircularStringWkt( QStringLiteral( "CIRCULARSTRING( 0.83 7.33, 0.5 0.5, 0 0 )" ) );
5318-
QgsCircularString *CCWCircularString = static_cast<QgsCircularString *>( QgsGeometryFactory::geomFromWkt( CCWCircularStringWkt ) );
5318+
QgsCircularString *CCWCircularString = static_cast<QgsCircularString *>( QgsGeometryFactory::geomFromWkt( CCWCircularStringWkt ).release() );
53195319
QgsLineString *CCWLineString = CCWCircularString->curveToLine();
53205320
QgsLineString *reversedCCWLineString = CCWLineString->reversed();
53215321

0 commit comments

Comments
 (0)
Please sign in to comment.