@@ -787,15 +787,15 @@ void TestQgsProcessing::mapLayers()
787
787
788
788
// Test layers from a string with parameters
789
789
QString osmFilePath = testDataDir + " openstreetmap/testdata.xml" ;
790
- QgsVectorLayer * osm = qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString ( osmFilePath ) );
790
+ std::unique_ptr< QgsVectorLayer > osm ( qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString ( osmFilePath ) ) );
791
791
QVERIFY ( osm->isValid () );
792
792
QCOMPARE ( osm->geometryType (), QgsWkbTypes::PointGeometry );
793
793
794
- osm = qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString ( osmFilePath + " |layerid=3" ) );
794
+ osm. reset ( qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString ( osmFilePath + " |layerid=3" ) ) );
795
795
QVERIFY ( osm->isValid () );
796
796
QCOMPARE ( osm->geometryType (), QgsWkbTypes::PolygonGeometry );
797
797
798
- osm = qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString ( osmFilePath + " |layerid=3|subset=\" building\" is not null" ) );
798
+ osm. reset ( qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString ( osmFilePath + " |layerid=3|subset=\" building\" is not null" ) ) );
799
799
QVERIFY ( osm->isValid () );
800
800
QCOMPARE ( osm->geometryType (), QgsWkbTypes::PolygonGeometry );
801
801
QCOMPARE ( osm->subsetString (), QStringLiteral ( " \" building\" is not null" ) );
@@ -966,6 +966,7 @@ void TestQgsProcessing::algorithm()
966
966
QVERIFY ( p2->algorithms ().isEmpty () );
967
967
p2->load ();
968
968
QCOMPARE ( p2->algorithms ().size (), 2 );
969
+ delete p2;
969
970
970
971
// test that adding a provider to the registry automatically refreshes algorithms (via load)
971
972
DummyProvider *p3 = new DummyProvider ( " p3" );
@@ -4471,24 +4472,24 @@ void TestQgsProcessing::combineLayerExtent()
4471
4472
QString raster1 = testDataDir + " tenbytenraster.asc" ;
4472
4473
QString raster2 = testDataDir + " landsat.tif" ;
4473
4474
QFileInfo fi1 ( raster1 );
4474
- QgsRasterLayer *r1 = new QgsRasterLayer ( fi1.filePath (), " R1" );
4475
+ std::unique_ptr< QgsRasterLayer > r1 ( new QgsRasterLayer ( fi1.filePath (), " R1" ) );
4475
4476
QFileInfo fi2 ( raster2 );
4476
- QgsRasterLayer *r2 = new QgsRasterLayer ( fi2.filePath (), " R2" );
4477
+ std::unique_ptr< QgsRasterLayer > r2 ( new QgsRasterLayer ( fi2.filePath (), " R2" ) );
4477
4478
4478
- ext = QgsProcessingUtils::combineLayerExtents ( QList< QgsMapLayer *>() << r1 );
4479
+ ext = QgsProcessingUtils::combineLayerExtents ( QList< QgsMapLayer *>() << r1. get () );
4479
4480
QGSCOMPARENEAR ( ext.xMinimum (), 1535375.000000 , 10 );
4480
4481
QGSCOMPARENEAR ( ext.xMaximum (), 1535475 , 10 );
4481
4482
QGSCOMPARENEAR ( ext.yMinimum (), 5083255 , 10 );
4482
4483
QGSCOMPARENEAR ( ext.yMaximum (), 5083355 , 10 );
4483
4484
4484
- ext = QgsProcessingUtils::combineLayerExtents ( QList< QgsMapLayer *>() << r1 << r2 );
4485
+ ext = QgsProcessingUtils::combineLayerExtents ( QList< QgsMapLayer *>() << r1. get () << r2. get () );
4485
4486
QGSCOMPARENEAR ( ext.xMinimum (), 781662 , 10 );
4486
4487
QGSCOMPARENEAR ( ext.xMaximum (), 1535475 , 10 );
4487
4488
QGSCOMPARENEAR ( ext.yMinimum (), 3339523 , 10 );
4488
4489
QGSCOMPARENEAR ( ext.yMaximum (), 5083355 , 10 );
4489
4490
4490
4491
// with reprojection
4491
- ext = QgsProcessingUtils::combineLayerExtents ( QList< QgsMapLayer *>() << r1 << r2, QgsCoordinateReferenceSystem::fromEpsgId ( 3785 ) );
4492
+ ext = QgsProcessingUtils::combineLayerExtents ( QList< QgsMapLayer *>() << r1. get () << r2. get () , QgsCoordinateReferenceSystem::fromEpsgId ( 3785 ) );
4492
4493
QGSCOMPARENEAR ( ext.xMinimum (), 1995320 , 10 );
4493
4494
QGSCOMPARENEAR ( ext.xMaximum (), 2008833 , 10 );
4494
4495
QGSCOMPARENEAR ( ext.yMinimum (), 3523084 , 10 );
@@ -5697,7 +5698,7 @@ void TestQgsProcessing::convertCompatible()
5697
5698
QVERIFY ( out.startsWith ( QgsProcessingUtils::tempFolder () ) );
5698
5699
5699
5700
// make sure all features are copied
5700
- QgsVectorLayer * t = new QgsVectorLayer ( out, " vl2" );
5701
+ std::unique_ptr< QgsVectorLayer > t = qgis::make_unique< QgsVectorLayer > ( out, " vl2" );
5701
5702
QCOMPARE ( layer->featureCount (), t->featureCount () );
5702
5703
QCOMPARE ( layer->crs (), t->crs () );
5703
5704
@@ -5715,17 +5716,15 @@ void TestQgsProcessing::convertCompatible()
5715
5716
QVERIFY ( out != layer->source () );
5716
5717
QVERIFY ( out.endsWith ( " .tab" ) );
5717
5718
QVERIFY ( out.startsWith ( QgsProcessingUtils::tempFolder () ) );
5718
- delete t;
5719
- t = new QgsVectorLayer ( out, " vl2" );
5719
+ t = qgis::make_unique< QgsVectorLayer >( out, " vl2" );
5720
5720
QCOMPARE ( t->featureCount (), static_cast < long >( ids.count () ) );
5721
5721
5722
5722
// using a selection but existing format - will still require translation
5723
5723
out = QgsProcessingUtils::convertToCompatibleFormat ( layer, true , QStringLiteral ( " test" ), QStringList () << " shp" , QString ( " shp" ), context, &feedback );
5724
5724
QVERIFY ( out != layer->source () );
5725
5725
QVERIFY ( out.endsWith ( " .shp" ) );
5726
5726
QVERIFY ( out.startsWith ( QgsProcessingUtils::tempFolder () ) );
5727
- delete t;
5728
- t = new QgsVectorLayer ( out, " vl2" );
5727
+ t = qgis::make_unique< QgsVectorLayer >( out, " vl2" );
5729
5728
QCOMPARE ( t->featureCount (), static_cast < long >( ids.count () ) );
5730
5729
5731
5730
0 commit comments