From 0ac9936b628b530682ad7e9436128c02e313c4eb Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 7 Feb 2025 09:24:45 +1000 Subject: [PATCH] Upgrade std::unique_ptr xx( new XX ) to auto/std::make_unique --- scripts/qstringfixup.py | 16 ++ src/analysis/mesh/qgsmeshcontours.cpp | 6 +- .../processing/qgsalgorithmdistancewithin.cpp | 2 +- .../qgsalgorithmextractbylocation.cpp | 4 +- .../qgsalgorithmmeshsurfacetopolygon.cpp | 4 +- .../processing/qgsalgorithmrescaleraster.cpp | 2 +- src/analysis/vector/qgsgeometrysnapper.cpp | 4 +- .../browser/qgsinbuiltdataitemproviders.cpp | 6 +- src/app/dwg/qgsdwgimportdialog.cpp | 4 +- src/app/dwg/qgsdwgimporter.cpp | 4 +- src/app/georeferencer/qgsgeoreftransform.cpp | 2 +- src/app/georeferencer/qgsgeoreftransform.h | 5 +- .../qgsactivelayerfeatureslocatorfilter.cpp | 2 +- .../qgsalllayersfeatureslocatorfilter.cpp | 2 +- .../qgsmaptoolshapecircle2tangentspoint.cpp | 8 +- .../maptools/qgsmaptoolshapecircle3points.cpp | 2 +- .../qgsmaptoolshapecircle3tangents.cpp | 2 +- .../qgsmaptoolshapecircularstringabstract.cpp | 4 +- .../qgsmaptoolshapeellipsecenter2points.cpp | 2 +- .../maptools/qgsmaptoolshapeellipsefoci.cpp | 2 +- .../qgsmaptoolshaperectangle3points.cpp | 2 +- src/app/mesh/qgsmaptooleditmeshframe.cpp | 2 +- src/auth/oauth2/core/qgsauthoauth2method.cpp | 2 +- src/core/annotations/qgshtmlannotation.cpp | 2 +- src/core/annotations/qgssvgannotation.cpp | 2 +- src/core/annotations/qgstextannotation.cpp | 2 +- .../expression/qgsexpressioncontextutils.cpp | 8 +- src/core/expression/qgsexpressionfunction.cpp | 4 +- src/core/geometry/qgscircle.cpp | 2 +- src/core/geometry/qgscurvepolygon.cpp | 4 +- src/core/geometry/qgsellipse.cpp | 4 +- src/core/geometry/qgsgeometrycollection.cpp | 2 +- src/core/geometry/qgsgeos.cpp | 12 +- src/core/geometry/qgsmulticurve.cpp | 2 +- src/core/geometry/qgsmultipolygon.cpp | 2 +- src/core/geometry/qgsmultisurface.cpp | 2 +- src/core/geometry/qgspolygon.cpp | 2 +- src/core/geometry/qgspolyhedralsurface.cpp | 2 +- src/core/geometry/qgsregularpolygon.cpp | 4 +- src/core/geometry/qgstriangle.cpp | 2 +- src/core/gps/qgsgpslogger.cpp | 4 +- src/core/layout/qgscompositionconverter.cpp | 2 +- src/core/layout/qgslayout.cpp | 6 +- src/core/layout/qgslayoutguidecollection.cpp | 4 +- src/core/layout/qgslayoutpagecollection.cpp | 2 +- src/core/mesh/qgsmeshadvancedediting.cpp | 2 +- src/core/mesh/qgsmeshforcebypolylines.cpp | 2 +- src/core/mesh/qgsmeshlayerinterpolator.cpp | 2 +- src/core/mesh/qgstopologicalmesh.cpp | 4 +- .../models/qgsprocessingmodelalgorithm.cpp | 2 +- src/core/processing/qgsprocessingutils.cpp | 2 +- src/core/project/qgsproject.cpp | 10 +- src/core/providers/qgsproviderregistry.cpp | 2 +- src/core/qgselevationmap.cpp | 2 +- src/core/qgsmaptopixelgeometrysimplifier.cpp | 2 +- src/core/qgsogcutils.cpp | 6 +- src/core/qgstessellator.cpp | 2 +- .../raster/qgsbrightnesscontrastfilter.cpp | 2 +- src/core/raster/qgshillshaderenderer.cpp | 2 +- src/core/raster/qgshuesaturationfilter.cpp | 2 +- src/core/raster/qgsmultibandcolorrenderer.cpp | 2 +- src/core/raster/qgspalettedrasterrenderer.cpp | 2 +- src/core/raster/qgsrastercontourrenderer.cpp | 2 +- src/core/raster/qgsrasterlayer.cpp | 2 +- src/core/raster/qgsrasternuller.cpp | 2 +- src/core/raster/qgsrasterresamplefilter.cpp | 2 +- .../raster/qgsrastersinglecolorrenderer.cpp | 2 +- .../raster/qgssinglebandcolordatarenderer.cpp | 2 +- src/core/raster/qgssinglebandgrayrenderer.cpp | 2 +- .../qgssinglebandpseudocolorrenderer.cpp | 2 +- src/core/symbology/qgsfillsymbollayer.cpp | 2 +- src/core/vector/qgsvectorlayerexporter.cpp | 2 +- .../vectortile/qgsvectortilemvtdecoder.cpp | 2 +- src/gui/layout/qgslayoutguidewidget.cpp | 4 +- src/gui/layout/qgslayoutview.cpp | 10 +- src/gui/plot/qgsplotcanvas.cpp | 10 +- .../models/qgsmodelgraphicsview.cpp | 8 +- .../ogr/qgsgeopackageitemguiprovider.cpp | 2 +- .../providers/ogr/qgsogrdbsourceselect.cpp | 2 +- src/gui/qgsformannotation.cpp | 2 +- src/gui/qgsguiutils.cpp | 2 +- src/gui/qgsmapcanvas.cpp | 10 +- src/gui/raster/qgsrasterlayerproperties.cpp | 2 +- src/providers/oracle/qgsoracleprovider.cpp | 2 +- .../postgres/qgspostgresdataitems.cpp | 2 +- .../postgres/qgspostgreslistener.cpp | 2 +- src/providers/postgres/qgspostgreslistener.h | 3 +- .../qgsspatialitedataitemguiprovider.cpp | 2 +- .../virtual/qgsvirtuallayersourceselect.cpp | 2 +- .../qgsvirtualrasterprovider.cpp | 2 +- src/server/qgsconfigcache.cpp | 2 +- src/server/services/wfs/qgswfsgetfeature.cpp | 2 +- src/server/services/wfs/qgswfstransaction.cpp | 2 +- .../services/wfs/qgswfstransaction_1_0_0.cpp | 2 +- src/server/services/wfs3/qgswfs3handlers.cpp | 10 +- .../services/wms/qgswmsgetlegendgraphics.cpp | 6 +- src/server/services/wms/qgswmsrenderer.cpp | 4 +- tests/src/3d/testqgs3drendering.cpp | 10 +- tests/src/analysis/testqgsprocessing.cpp | 108 ++++++------ tests/src/analysis/testqgszonalstatistics.cpp | 2 +- tests/src/app/testqgsattributetable.cpp | 74 ++++---- tests/src/app/testqgsfieldcalculator.cpp | 12 +- tests/src/app/testqgsidentify.cpp | 52 +++--- tests/src/app/testqgsmaptoollabel.cpp | 8 +- tests/src/app/testqgsmaptoolreshape.cpp | 2 +- tests/src/app/testqgsmaptoolreverseline.cpp | 12 +- tests/src/app/testqgsmaptoolselect.cpp | 4 +- .../app/testqgsmaptooltrimextendfeature.cpp | 10 +- tests/src/app/testqgsmeasuretool.cpp | 42 ++--- tests/src/app/testqgsmeshcalculatordialog.cpp | 2 +- tests/src/app/testqgsprojectproperties.cpp | 2 +- .../app/testqgsvectorlayersaveasdialog.cpp | 2 +- tests/src/core/geometry/testqgscircle.cpp | 4 +- .../core/geometry/testqgscircularstring.cpp | 4 +- .../src/core/geometry/testqgscurvepolygon.cpp | 4 +- tests/src/core/geometry/testqgsellipse.cpp | 4 +- tests/src/core/geometry/testqgslinestring.cpp | 6 +- .../core/geometry/testqgsregularpolygon.cpp | 2 +- tests/src/core/geometry/testqgstriangle.cpp | 16 +- tests/src/core/testqgis.cpp | 2 +- tests/src/core/testqgscallout.cpp | 50 +++--- tests/src/core/testqgsdiagram.cpp | 2 +- tests/src/core/testqgsexpressioncontext.cpp | 2 +- tests/src/core/testqgsfield.cpp | 2 +- tests/src/core/testqgsgdalutils.cpp | 4 +- tests/src/core/testqgslabelingengine.cpp | 160 +++++++++--------- tests/src/core/testqgslayoutatlas.cpp | 2 +- tests/src/core/testqgslayoutitem.cpp | 26 +-- tests/src/core/testqgslayoutpage.cpp | 22 +-- tests/src/core/testqgslayoutpicture.cpp | 2 +- tests/src/core/testqgslayoutshapes.cpp | 8 +- tests/src/core/testqgslegendrenderer.cpp | 18 +- tests/src/core/testqgsmaprendererjob.cpp | 2 +- tests/src/core/testqgsmapsettingsutils.cpp | 2 +- tests/src/core/testqgsmeshlayer.cpp | 2 +- tests/src/core/testqgspainteffect.cpp | 4 +- tests/src/core/testqgspallabeling.cpp | 4 +- tests/src/core/testqgspointlocator.cpp | 4 +- tests/src/core/testqgsrasterfilewriter.cpp | 2 +- tests/src/core/testqgssnappingutils.cpp | 14 +- tests/src/core/testqgsspatialindexkdbush.cpp | 4 +- tests/src/core/testqgsstyle.cpp | 16 +- tests/src/core/testqgstaskmanager.cpp | 4 +- tests/src/gui/testqgsdualview.cpp | 2 +- .../gui/testqgsexternalstoragefilewidget.cpp | 6 +- tests/src/gui/testqgsfeaturelistcombobox.cpp | 12 +- .../src/gui/testqgsfieldexpressionwidget.cpp | 8 +- tests/src/gui/testqgsfilewidget.cpp | 6 +- .../gui/testqgsvaluerelationwidgetwrapper.cpp | 8 +- 149 files changed, 564 insertions(+), 548 deletions(-) diff --git a/scripts/qstringfixup.py b/scripts/qstringfixup.py index 8b1994fe4bf..eee3c2b8e6e 100644 --- a/scripts/qstringfixup.py +++ b/scripts/qstringfixup.py @@ -99,6 +99,9 @@ make_unique = re.compile( make_unique2 = re.compile( r"""^(\s*)std::unique_ptr<\s*(.*?)\s*>(?:\s*(.*?)\s*\()\s*(std::make_unique<\s*(.*?)\s*>.*?)\s*\)\s*;$""" ) +make_unique3 = re.compile( + r"""^(\s*)std::unique_ptr<\s*(.*?)\s*>(?:\s*(.*?)\s*\()\s*new\s*(.*?)\s*(\(.*\s*\))\s*\)\s*;""" +) def qlatin1char_or_string(x): @@ -240,5 +243,18 @@ while i < len(lines): if m and m.group(2) == m.group(5): line = m.group(1) + "auto " + m.group(3) + " = " + m.group(4) + ";" + m = make_unique3.match(line) + if m and m.group(2) == m.group(4): + line = ( + m.group(1) + + "auto " + + m.group(3) + + " = std::make_unique<" + + m.group(4) + + ">" + + m.group(5) + + ";" + ) + print(line) i += 1 diff --git a/src/analysis/mesh/qgsmeshcontours.cpp b/src/analysis/mesh/qgsmeshcontours.cpp index d07784ff10d..e07d9d93947 100644 --- a/src/analysis/mesh/qgsmeshcontours.cpp +++ b/src/analysis/mesh/qgsmeshcontours.cpp @@ -268,7 +268,7 @@ QgsGeometry QgsMeshContours::exportLines( const QgsMeshDatasetIndex &index, doub QgsGeometry QgsMeshContours::exportLines( double value, QgsFeedback *feedback ) { - std::unique_ptr multiLineString( new QgsMultiLineString() ); + auto multiLineString = std::make_unique(); QSet> exactEdges; // STEP 1: Get Data @@ -337,7 +337,7 @@ QgsGeometry QgsMeshContours::exportLines( double value, QgsFeedback *feedback ) else { exactEdges.insert( { indices[i], indices[j] } ); - std::unique_ptr line( new QgsLineString( coords[i], coords[j] ) ); + auto line = std::make_unique( coords[i], coords[j] ); multiLineString->addGeometry( line.release() ); break; } @@ -361,7 +361,7 @@ QgsGeometry QgsMeshContours::exportLines( double value, QgsFeedback *feedback ) else { // we have found the end point of the contour line, we are done - std::unique_ptr line( new QgsLineString( tmp, xy ) ); + auto line = std::make_unique( tmp, xy ); multiLineString->addGeometry( line.release() ); break; } diff --git a/src/analysis/processing/qgsalgorithmdistancewithin.cpp b/src/analysis/processing/qgsalgorithmdistancewithin.cpp index 31fb6046f8b..6e3945f0517 100644 --- a/src/analysis/processing/qgsalgorithmdistancewithin.cpp +++ b/src/analysis/processing/qgsalgorithmdistancewithin.cpp @@ -23,7 +23,7 @@ void QgsDistanceWithinAlgorithm::addDistanceParameter() { - std::unique_ptr distanceParam( new QgsProcessingParameterDistance( QStringLiteral( "DISTANCE" ), QObject::tr( "Where the features are within" ), 100, QStringLiteral( "INPUT" ), false, 0 ) ); + auto distanceParam = std::make_unique( QStringLiteral( "DISTANCE" ), QObject::tr( "Where the features are within" ), 100, QStringLiteral( "INPUT" ), false, 0 ); distanceParam->setIsDynamic( true ); distanceParam->setDynamicPropertyDefinition( QgsPropertyDefinition( QStringLiteral( "Distance" ), QObject::tr( "Distance within" ), QgsPropertyDefinition::DoublePositive ) ); distanceParam->setDynamicLayerParameterName( QStringLiteral( "INPUT" ) ); diff --git a/src/analysis/processing/qgsalgorithmextractbylocation.cpp b/src/analysis/processing/qgsalgorithmextractbylocation.cpp index a9fda047875..339a901a37e 100644 --- a/src/analysis/processing/qgsalgorithmextractbylocation.cpp +++ b/src/analysis/processing/qgsalgorithmextractbylocation.cpp @@ -24,7 +24,7 @@ void QgsLocationBasedAlgorithm::addPredicateParameter() { - std::unique_ptr predicateParam( new QgsProcessingParameterEnum( QStringLiteral( "PREDICATE" ), QObject::tr( "Where the features (geometric predicate)" ), predicateOptionsList(), true, QVariant::fromValue( QList() << 0 ) ) ); + auto predicateParam = std::make_unique( QStringLiteral( "PREDICATE" ), QObject::tr( "Where the features (geometric predicate)" ), predicateOptionsList(), true, QVariant::fromValue( QList() << 0 ) ); QVariantMap predicateMetadata; QVariantMap widgetMetadata; @@ -423,7 +423,7 @@ QVariantMap QgsSelectByLocationAlgorithm::processAlgorithm( const QVariantMap &p case Qgis::SelectBehavior::RemoveFromSelection: { // When subsetting or removing we only need to check already selected features - std::unique_ptr selectLayerSelected( new QgsVectorLayerSelectedFeatureSource( selectLayer ) ); + auto selectLayerSelected = std::make_unique( selectLayer ); mTargetCrs = selectLayerSelected->sourceCrs(); mTargetFeatureCount = selectLayerSelected->featureCount(); process( context, selectLayerSelected.get(), intersectSource.get(), selectedPredicates, addToSelection, true, feedback ); diff --git a/src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp b/src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp index 9ebdf4ba393..88e00407dbb 100644 --- a/src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp +++ b/src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp @@ -173,7 +173,7 @@ QVariantMap QgsMeshSurfaceToPolygonAlgorithm::processAlgorithm( const QVariantMa feedback->setProgressText( QObject::tr( "Parsing mesh edges." ) ); } - std::unique_ptr multiLineString( new QgsMultiLineString() ); + auto multiLineString = std::make_unique(); int i = 0; for ( auto it = edges.begin(); it != edges.end(); it++ ) @@ -187,7 +187,7 @@ QVariantMap QgsMeshSurfaceToPolygonAlgorithm::processAlgorithm( const QVariantMa // only consider edges with count 1 which are on the edge of mesh surface if ( it.value() == 1 ) { - std::unique_ptr line( new QgsLineString( mNativeMesh.vertex( it.key().first ), mNativeMesh.vertex( it.key().second ) ) ); + auto line = std::make_unique( mNativeMesh.vertex( it.key().first ), mNativeMesh.vertex( it.key().second ) ); multiLineString->addGeometry( line.release() ); } diff --git a/src/analysis/processing/qgsalgorithmrescaleraster.cpp b/src/analysis/processing/qgsalgorithmrescaleraster.cpp index d56d60190ad..c28c51a26e3 100644 --- a/src/analysis/processing/qgsalgorithmrescaleraster.cpp +++ b/src/analysis/processing/qgsalgorithmrescaleraster.cpp @@ -168,7 +168,7 @@ QVariantMap QgsRescaleRasterAlgorithm::processAlgorithm( const QVariantMap ¶ std::unique_ptr inputBlock; while ( iter.readNextRasterPart( mBand, iterCols, iterRows, inputBlock, iterLeft, iterTop ) ) { - std::unique_ptr outputBlock( new QgsRasterBlock( destProvider->dataType( 1 ), iterCols, iterRows ) ); + auto outputBlock = std::make_unique( destProvider->dataType( 1 ), iterCols, iterRows ); feedback->setProgress( 100 * ( ( iterTop / blockHeight * numBlocksX ) + iterLeft / blockWidth ) / numBlocks ); for ( int row = 0; row < iterRows; row++ ) diff --git a/src/analysis/vector/qgsgeometrysnapper.cpp b/src/analysis/vector/qgsgeometrysnapper.cpp index d263bb2e7a7..8b2908fa56b 100644 --- a/src/analysis/vector/qgsgeometrysnapper.cpp +++ b/src/analysis/vector/qgsgeometrysnapper.cpp @@ -474,11 +474,11 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry &geometry, doubl return result; } - std::unique_ptr subjSnapIndex( new QgsSnapIndex() ); + auto subjSnapIndex = std::make_unique(); subjSnapIndex->addGeometry( subjGeom ); std::unique_ptr origSubjGeom( subjGeom->clone() ); - std::unique_ptr origSubjSnapIndex( new QgsSnapIndex() ); + auto origSubjSnapIndex = std::make_unique(); origSubjSnapIndex->addGeometry( origSubjGeom.get() ); // Pass 2: add missing vertices to subject geometry diff --git a/src/app/browser/qgsinbuiltdataitemproviders.cpp b/src/app/browser/qgsinbuiltdataitemproviders.cpp index 058b3d98dc6..121d0bce532 100644 --- a/src/app/browser/qgsinbuiltdataitemproviders.cpp +++ b/src/app/browser/qgsinbuiltdataitemproviders.cpp @@ -1021,7 +1021,7 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men case Qgis::LayerType::Vector: { const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; - std::unique_ptr layer( new QgsVectorLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey(), options ) ); + auto layer = std::make_unique( layerItem->uri(), layerItem->name(), layerItem->providerKey(), options ); if ( layer && layer->isValid() ) { QgisApp::instance()->saveAsFile( layer.get(), false, false ); @@ -1031,7 +1031,7 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men case Qgis::LayerType::Raster: { - std::unique_ptr layer( new QgsRasterLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey() ) ); + auto layer = std::make_unique( layerItem->uri(), layerItem->name(), layerItem->providerKey() ); if ( layer && layer->isValid() ) { QgisApp::instance()->saveAsFile( layer.get(), false, false ); @@ -1900,7 +1900,7 @@ bool QgsDatabaseItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiCo bool hasError = false; // Main task - std::unique_ptr mainTask( new QgsTaskWithSerialSubTasks( tr( "Layer import" ) ) ); + auto mainTask = std::make_unique( tr( "Layer import" ) ); bool hasSubTasks = false; const QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( data ); diff --git a/src/app/dwg/qgsdwgimportdialog.cpp b/src/app/dwg/qgsdwgimportdialog.cpp index 8d4cbc1ccae..06eca8c4a81 100644 --- a/src/app/dwg/qgsdwgimportdialog.cpp +++ b/src/app/dwg/qgsdwgimportdialog.cpp @@ -186,7 +186,7 @@ void QgsDwgImportDialog::pbLoadDatabase_clicked() QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; options.loadDefaultStyle = false; - std::unique_ptr d( new QgsVectorLayer( QStringLiteral( "%1|layername=drawing" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), options ) ); + auto d = std::make_unique( QStringLiteral( "%1|layername=drawing" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), options ); if ( d && d->isValid() ) { const int idxPath = d->fields().lookupField( QStringLiteral( "path" ) ); @@ -227,7 +227,7 @@ void QgsDwgImportDialog::pbLoadDatabase_clicked() lblMessage->setVisible( lblVisible ); - std::unique_ptr l( new QgsVectorLayer( QStringLiteral( "%1|layername=layers" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), options ) ); + auto l = std::make_unique( QStringLiteral( "%1|layername=layers" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), options ); if ( l && l->isValid() ) { const int idxName = l->fields().lookupField( QStringLiteral( "name" ) ); diff --git a/src/app/dwg/qgsdwgimporter.cpp b/src/app/dwg/qgsdwgimporter.cpp index 5d68c1b5409..d0126edc2a8 100644 --- a/src/app/dwg/qgsdwgimporter.cpp +++ b/src/app/dwg/qgsdwgimporter.cpp @@ -631,7 +631,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa if ( fi.suffix().compare( QLatin1String( "dxf" ), Qt::CaseInsensitive ) == 0 ) { //loads dxf - std::unique_ptr dxf( new dxfRW( drawing.toLocal8Bit() ) ); + auto dxf = std::make_unique( drawing.toLocal8Bit() ); if ( !dxf->read( this, true ) ) { result = DRW::BAD_UNKNOWN; @@ -640,7 +640,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa else if ( fi.suffix().compare( QLatin1String( "dwg" ), Qt::CaseInsensitive ) == 0 ) { //loads dwg - std::unique_ptr dwg( new dwgR( drawing.toLocal8Bit() ) ); + auto dwg = std::make_unique( drawing.toLocal8Bit() ); if ( !dwg->read( this, true ) ) { result = dwg->getError(); diff --git a/src/app/georeferencer/qgsgeoreftransform.cpp b/src/app/georeferencer/qgsgeoreftransform.cpp index 4ffdcb20115..01838b9b8b0 100644 --- a/src/app/georeferencer/qgsgeoreftransform.cpp +++ b/src/app/georeferencer/qgsgeoreftransform.cpp @@ -76,7 +76,7 @@ bool QgsGeorefTransform::parametersInitialized() const QgsGcpTransformerInterface *QgsGeorefTransform::clone() const { - std::unique_ptr res( new QgsGeorefTransform( *this ) ); + auto res = std::make_unique( *this ); res->updateParametersFromGcps( mSourceCoordinates, mDestinationCoordinates, mInvertYAxis ); return res.release(); } diff --git a/src/app/georeferencer/qgsgeoreftransform.h b/src/app/georeferencer/qgsgeoreftransform.h index 587ec1a5e28..2a46e583b71 100644 --- a/src/app/georeferencer/qgsgeoreftransform.h +++ b/src/app/georeferencer/qgsgeoreftransform.h @@ -40,6 +40,9 @@ class APP_EXPORT QgsGeorefTransform : public QgsGcpTransformerInterface QgsGeorefTransform(); ~QgsGeorefTransform() override; + //! shallow copy constructor + QgsGeorefTransform( const QgsGeorefTransform &other ); + /** * Switches the used transform type to the given parametrisation. */ @@ -116,8 +119,6 @@ class APP_EXPORT QgsGeorefTransform : public QgsGcpTransformerInterface bool getOriginScaleRotation( QgsPointXY &origin, double &scaleX, double &scaleY, double &rotation ) const; private: - // shallow copy constructor - QgsGeorefTransform( const QgsGeorefTransform &other ); QgsGeorefTransform &operator=( const QgsGeorefTransform & ) = delete; bool transformPrivate( const QgsPointXY &src, QgsPointXY &dst, bool inverseTransform ) const; diff --git a/src/app/locator/qgsactivelayerfeatureslocatorfilter.cpp b/src/app/locator/qgsactivelayerfeatureslocatorfilter.cpp index b3a074af898..b63b0a54a55 100644 --- a/src/app/locator/qgsactivelayerfeatureslocatorfilter.cpp +++ b/src/app/locator/qgsactivelayerfeatureslocatorfilter.cpp @@ -327,7 +327,7 @@ void QgsActiveLayerFeaturesLocatorFilter::openConfigWidget( QWidget *parent ) { QString key = "locator_filters/active_layer_features"; QgsSettings settings; - std::unique_ptr dlg( new QDialog( parent ) ); + auto dlg = std::make_unique( parent ); dlg->restoreGeometry( settings.value( QStringLiteral( "Windows/%1/geometry" ).arg( key ) ).toByteArray() ); dlg->setWindowTitle( "All layers features locator filter" ); QFormLayout *formLayout = new QFormLayout; diff --git a/src/app/locator/qgsalllayersfeatureslocatorfilter.cpp b/src/app/locator/qgsalllayersfeatureslocatorfilter.cpp index 5426fad2b4c..ddcd95a5815 100644 --- a/src/app/locator/qgsalllayersfeatureslocatorfilter.cpp +++ b/src/app/locator/qgsalllayersfeatureslocatorfilter.cpp @@ -217,7 +217,7 @@ void QgsAllLayersFeaturesLocatorFilter::openConfigWidget( QWidget *parent ) { QString key = "locator_filters/all_layers_features"; QgsSettings settings; - std::unique_ptr dlg( new QDialog( parent ) ); + auto dlg = std::make_unique( parent ); dlg->restoreGeometry( settings.value( QStringLiteral( "Windows/%1/geometry" ).arg( key ) ).toByteArray() ); dlg->setWindowTitle( "All layers features locator filter" ); QFormLayout *formLayout = new QFormLayout; diff --git a/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.cpp b/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.cpp index 263824fbf78..9d946753bbf 100644 --- a/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.cpp +++ b/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.cpp @@ -129,7 +129,7 @@ void QgsMapToolShapeCircle2TangentsPoint::cadCanvasMoveEvent( QgsMapMouseEvent * { QgsPointXY p1, p2; match.edgePoints( p1, p2 ); - std::unique_ptr line( new QgsLineString() ); + auto line = std::make_unique(); line->addVertex( QgsPoint( p1 ) ); line->addVertex( QgsPoint( p2 ) ); @@ -161,11 +161,11 @@ void QgsMapToolShapeCircle2TangentsPoint::getPossibleCenter() if ( mPoints.size() == 4 ) { - std::unique_ptr l1( new QgsLineString() ); + auto l1 = std::make_unique(); l1->addVertex( mPoints.at( 0 ) ); l1->addVertex( mPoints.at( 1 ) ); - std::unique_ptr l2( new QgsLineString() ); + auto l2 = std::make_unique(); l2->addVertex( mPoints.at( 2 ) ); l2->addVertex( mPoints.at( 3 ) ); @@ -227,7 +227,7 @@ void QgsMapToolShapeCircle2TangentsPoint::radiusSpinBoxChanged( double radius ) for ( int i = 0; i < mCenters.size(); ++i ) { std::unique_ptr tempRB( mParentTool->createGeometryRubberBand( Qgis::GeometryType::Point, true ) ); - std::unique_ptr tempCenter( new QgsPoint( mCenters.at( i ) ) ); + auto tempCenter = std::make_unique( mCenters.at( i ) ); tempRB->setGeometry( tempCenter.release() ); tempRB->show(); mRubberBands.append( tempRB.release() ); diff --git a/src/app/maptools/qgsmaptoolshapecircle3points.cpp b/src/app/maptools/qgsmaptoolshapecircle3points.cpp index 1b37cdd23c6..bfc21a431ea 100644 --- a/src/app/maptools/qgsmaptoolshapecircle3points.cpp +++ b/src/app/maptools/qgsmaptoolshapecircle3points.cpp @@ -84,7 +84,7 @@ void QgsMapToolShapeCircle3Points::cadCanvasMoveEvent( QgsMapMouseEvent *e, QgsM { case 1: { - std::unique_ptr line( new QgsLineString() ); + auto line = std::make_unique(); line->addVertex( mPoints.at( 0 ) ); line->addVertex( mParentTool->mapPoint( *e ) ); mTempRubberBand->setGeometry( line.release() ); diff --git a/src/app/maptools/qgsmaptoolshapecircle3tangents.cpp b/src/app/maptools/qgsmaptoolshapecircle3tangents.cpp index a79b770edb0..d107b055bf9 100644 --- a/src/app/maptools/qgsmaptoolshapecircle3tangents.cpp +++ b/src/app/maptools/qgsmaptoolshapecircle3tangents.cpp @@ -145,7 +145,7 @@ void QgsMapToolShapeCircle3Tangents::cadCanvasMoveEvent( QgsMapMouseEvent *e, Qg } else { - std::unique_ptr line( new QgsLineString() ); + auto line = std::make_unique(); line->addVertex( mParentTool->mapPoint( p1 ) ); line->addVertex( mParentTool->mapPoint( p2 ) ); diff --git a/src/app/maptools/qgsmaptoolshapecircularstringabstract.cpp b/src/app/maptools/qgsmaptoolshapecircularstringabstract.cpp index 2ac02acae48..7fcb70f88e7 100644 --- a/src/app/maptools/qgsmaptoolshapecircularstringabstract.cpp +++ b/src/app/maptools/qgsmaptoolshapecircularstringabstract.cpp @@ -61,8 +61,8 @@ void QgsMapToolShapeCircularStringAbstract::undo() if ( mPoints.size() > 1 ) { mPoints.removeLast(); - std::unique_ptr geomRubberBand( new QgsCircularString() ); - std::unique_ptr geomTempRubberBand( new QgsLineString() ); + auto geomRubberBand = std::make_unique(); + auto geomTempRubberBand = std::make_unique(); const int lastPositionCompleteCircularString = mPoints.size() - 1 - ( mPoints.size() + 1 ) % 2; geomTempRubberBand->setPoints( mPoints.mid( lastPositionCompleteCircularString ) ); diff --git a/src/app/maptools/qgsmaptoolshapeellipsecenter2points.cpp b/src/app/maptools/qgsmaptoolshapeellipsecenter2points.cpp index 4f77c324f28..1346918bd5b 100644 --- a/src/app/maptools/qgsmaptoolshapeellipsecenter2points.cpp +++ b/src/app/maptools/qgsmaptoolshapeellipsecenter2points.cpp @@ -87,7 +87,7 @@ void QgsMapToolShapeEllipseCenter2Points::cadCanvasMoveEvent( QgsMapMouseEvent * { case 1: { - std::unique_ptr line( new QgsLineString() ); + auto line = std::make_unique(); line->addVertex( mPoints.at( 0 ) ); line->addVertex( point ); mTempRubberBand->setGeometry( line.release() ); diff --git a/src/app/maptools/qgsmaptoolshapeellipsefoci.cpp b/src/app/maptools/qgsmaptoolshapeellipsefoci.cpp index 988d54f2362..48d507d566c 100644 --- a/src/app/maptools/qgsmaptoolshapeellipsefoci.cpp +++ b/src/app/maptools/qgsmaptoolshapeellipsefoci.cpp @@ -93,7 +93,7 @@ void QgsMapToolShapeEllipseFoci::cadCanvasMoveEvent( QgsMapMouseEvent *e, QgsMap { case 1: { - std::unique_ptr line( new QgsLineString() ); + auto line = std::make_unique(); line->addVertex( mPoints.at( 0 ) ); line->addVertex( point ); mTempRubberBand->setGeometry( line.release() ); diff --git a/src/app/maptools/qgsmaptoolshaperectangle3points.cpp b/src/app/maptools/qgsmaptoolshaperectangle3points.cpp index a7fd5b6380a..eeca53b718b 100644 --- a/src/app/maptools/qgsmaptoolshaperectangle3points.cpp +++ b/src/app/maptools/qgsmaptoolshaperectangle3points.cpp @@ -134,7 +134,7 @@ void QgsMapToolShapeRectangle3Points::cadCanvasMoveEvent( QgsMapMouseEvent *e, Q { case 1: { - std::unique_ptr line( new QgsLineString() ); + auto line = std::make_unique(); line->addVertex( mPoints.at( 0 ) ); line->addVertex( point ); mTempRubberBand->setGeometry( line.release() ); diff --git a/src/app/mesh/qgsmaptooleditmeshframe.cpp b/src/app/mesh/qgsmaptooleditmeshframe.cpp index e761b82ba38..1d58fe0b7d8 100644 --- a/src/app/mesh/qgsmaptooleditmeshframe.cpp +++ b/src/app/mesh/qgsmaptooleditmeshframe.cpp @@ -2064,7 +2064,7 @@ void QgsMapToolEditMeshFrame::selectTouchedByGeometry( const QgsGeometry &geomet for ( const int faceIndex : nativeFaceIndexes ) { const QgsMeshFace &face = nativeFace( faceIndex ); - std::unique_ptr faceGeom( new QgsPolygon( new QgsLineString( nativeFaceGeometry( faceIndex ) ) ) ); + auto faceGeom = std::make_unique( new QgsLineString( nativeFaceGeometry( faceIndex ) ) ); if ( engine->intersects( faceGeom.get() ) ) { QSet faceToAdd = qgis::listToSet( face.toList() ); diff --git a/src/auth/oauth2/core/qgsauthoauth2method.cpp b/src/auth/oauth2/core/qgsauthoauth2method.cpp index ac9858de8dc..8e9f1326e08 100644 --- a/src/auth/oauth2/core/qgsauthoauth2method.cpp +++ b/src/auth/oauth2/core/qgsauthoauth2method.cpp @@ -603,7 +603,7 @@ QgsO2 *QgsAuthOAuth2Method::getOAuth2Bundle( const QString &authcfg, bool fullco // do loading of method config into oauth2 config - std::unique_ptr config( new QgsAuthOAuth2Config() ); + auto config = std::make_unique(); if ( configmap.contains( QStringLiteral( "oauth2config" ) ) ) { const QByteArray configtxt = configmap.value( QStringLiteral( "oauth2config" ) ).toUtf8(); diff --git a/src/core/annotations/qgshtmlannotation.cpp b/src/core/annotations/qgshtmlannotation.cpp index 1168826bad7..764503a67ce 100644 --- a/src/core/annotations/qgshtmlannotation.cpp +++ b/src/core/annotations/qgshtmlannotation.cpp @@ -57,7 +57,7 @@ QgsHtmlAnnotation::QgsHtmlAnnotation( QObject *parent ) QgsHtmlAnnotation *QgsHtmlAnnotation::clone() const { - std::unique_ptr< QgsHtmlAnnotation > c( new QgsHtmlAnnotation() ); + auto c = std::make_unique(); copyCommonProperties( c.get() ); c->setSourceFile( mHtmlFile ); return c.release(); diff --git a/src/core/annotations/qgssvgannotation.cpp b/src/core/annotations/qgssvgannotation.cpp index 33d97d60d14..44a867f56ca 100644 --- a/src/core/annotations/qgssvgannotation.cpp +++ b/src/core/annotations/qgssvgannotation.cpp @@ -34,7 +34,7 @@ QgsSvgAnnotation::QgsSvgAnnotation( QObject *parent ) QgsSvgAnnotation *QgsSvgAnnotation::clone() const { - std::unique_ptr< QgsSvgAnnotation > c( new QgsSvgAnnotation() ); + auto c = std::make_unique(); copyCommonProperties( c.get() ); c->setFilePath( mFilePath ); return c.release(); diff --git a/src/core/annotations/qgstextannotation.cpp b/src/core/annotations/qgstextannotation.cpp index 0496ec90c9d..77bf0f42d3c 100644 --- a/src/core/annotations/qgstextannotation.cpp +++ b/src/core/annotations/qgstextannotation.cpp @@ -30,7 +30,7 @@ QgsTextAnnotation::QgsTextAnnotation( QObject *parent ) QgsTextAnnotation *QgsTextAnnotation::clone() const { - std::unique_ptr< QgsTextAnnotation > c( new QgsTextAnnotation() ); + auto c = std::make_unique(); copyCommonProperties( c.get() ); c->setDocument( mDocument.get() ); return c.release(); diff --git a/src/core/expression/qgsexpressioncontextutils.cpp b/src/core/expression/qgsexpressioncontextutils.cpp index abb4a375306..2411d575272 100644 --- a/src/core/expression/qgsexpressioncontextutils.cpp +++ b/src/core/expression/qgsexpressioncontextutils.cpp @@ -604,7 +604,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::updateSymbolScope( const Q QgsExpressionContextScope *QgsExpressionContextUtils::layoutScope( const QgsLayout *layout ) { - std::unique_ptr< QgsExpressionContextScope > scope( new QgsExpressionContextScope( QObject::tr( "Layout" ) ) ); + auto scope = std::make_unique( QObject::tr( "Layout" ) ); if ( !layout ) return scope.release(); @@ -901,7 +901,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::processingAlgorithmScope( // set aside for future use Q_UNUSED( context ) - std::unique_ptr< QgsExpressionContextScope > scope( new QgsExpressionContextScope( QObject::tr( "Algorithm" ) ) ); + auto scope = std::make_unique( QObject::tr( "Algorithm" ) ); scope->addFunction( QStringLiteral( "parameter" ), new GetProcessingParameterValue( parameters ) ); if ( !algorithm ) @@ -915,7 +915,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::processingAlgorithmScope( QgsExpressionContextScope *QgsExpressionContextUtils::processingModelAlgorithmScope( const QgsProcessingModelAlgorithm *model, const QVariantMap &, QgsProcessingContext &context ) { - std::unique_ptr< QgsExpressionContextScope > modelScope( new QgsExpressionContextScope( QObject::tr( "Model" ) ) ); + auto modelScope = std::make_unique( QObject::tr( "Model" ) ); QString modelPath; if ( !model->sourceFilePath().isEmpty() ) { @@ -946,7 +946,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::processingModelAlgorithmSc QgsExpressionContextScope *QgsExpressionContextUtils::notificationScope( const QString &message ) { - std::unique_ptr< QgsExpressionContextScope > scope( new QgsExpressionContextScope() ); + auto scope = std::make_unique(); scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "notification_message" ), message, true ) ); return scope.release(); } diff --git a/src/core/expression/qgsexpressionfunction.cpp b/src/core/expression/qgsexpressionfunction.cpp index de23f7abd7c..6e6aeaf4a92 100644 --- a/src/core/expression/qgsexpressionfunction.cpp +++ b/src/core/expression/qgsexpressionfunction.cpp @@ -3871,8 +3871,8 @@ static QVariant fcnMakePolygon( const QVariantList &values, const QgsExpressionC static QVariant fcnMakeTriangle( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) { - std::unique_ptr tr( new QgsTriangle() ); - std::unique_ptr lineString( new QgsLineString() ); + auto tr = std::make_unique(); + auto lineString = std::make_unique(); lineString->clear(); for ( const QVariant &value : values ) diff --git a/src/core/geometry/qgscircle.cpp b/src/core/geometry/qgscircle.cpp index 0dfcd7f2c57..b18d1c0442c 100644 --- a/src/core/geometry/qgscircle.cpp +++ b/src/core/geometry/qgscircle.cpp @@ -429,7 +429,7 @@ QVector QgsCircle::northQuadrant() const QgsCircularString *QgsCircle::toCircularString( bool oriented ) const { - std::unique_ptr circString( new QgsCircularString() ); + auto circString = std::make_unique(); QgsPointSequence points; QVector quad; if ( oriented ) diff --git a/src/core/geometry/qgscurvepolygon.cpp b/src/core/geometry/qgscurvepolygon.cpp index 24e035cc503..737ef8f1e41 100644 --- a/src/core/geometry/qgscurvepolygon.cpp +++ b/src/core/geometry/qgscurvepolygon.cpp @@ -515,7 +515,7 @@ double QgsCurvePolygon::roundness() const QgsPolygon *QgsCurvePolygon::surfaceToPolygon() const { - std::unique_ptr< QgsPolygon > polygon( new QgsPolygon() ); + auto polygon = std::make_unique(); if ( !mExteriorRing ) return polygon.release(); @@ -685,7 +685,7 @@ bool QgsCurvePolygon::boundingBoxIntersects( const QgsBox3D &box3d ) const QgsPolygon *QgsCurvePolygon::toPolygon( double tolerance, SegmentationToleranceType toleranceType ) const { - std::unique_ptr< QgsPolygon > poly( new QgsPolygon() ); + auto poly = std::make_unique(); if ( !mExteriorRing ) { return poly.release(); diff --git a/src/core/geometry/qgsellipse.cpp b/src/core/geometry/qgsellipse.cpp index 43775447bf9..4dafc0ef9b1 100644 --- a/src/core/geometry/qgsellipse.cpp +++ b/src/core/geometry/qgsellipse.cpp @@ -259,7 +259,7 @@ void QgsEllipse::pointsInternal( unsigned int segments, QVector &x, QVec QgsPolygon *QgsEllipse::toPolygon( unsigned int segments ) const { - std::unique_ptr polygon( new QgsPolygon() ); + auto polygon = std::make_unique(); if ( segments < 3 ) { return polygon.release(); @@ -337,7 +337,7 @@ QString QgsEllipse::toString( int pointPrecision, int axisPrecision, int azimuth QgsPolygon *QgsEllipse::orientedBoundingBox() const { - std::unique_ptr ombb( new QgsPolygon() ); + auto ombb = std::make_unique(); if ( isEmpty() ) { return ombb.release(); diff --git a/src/core/geometry/qgsgeometrycollection.cpp b/src/core/geometry/qgsgeometrycollection.cpp index a0728c6da8d..49c7d20760b 100644 --- a/src/core/geometry/qgsgeometrycollection.cpp +++ b/src/core/geometry/qgsgeometrycollection.cpp @@ -1057,7 +1057,7 @@ void QgsGeometryCollection::swapXy() QgsGeometryCollection *QgsGeometryCollection::toCurveType() const { - std::unique_ptr< QgsGeometryCollection > newCollection( new QgsGeometryCollection() ); + auto newCollection = std::make_unique(); newCollection->reserve( mGeometries.size() ); for ( QgsAbstractGeometry *geom : mGeometries ) { diff --git a/src/core/geometry/qgsgeos.cpp b/src/core/geometry/qgsgeos.cpp index 214c5c6734d..298acd334b4 100644 --- a/src/core/geometry/qgsgeos.cpp +++ b/src/core/geometry/qgsgeos.cpp @@ -1600,7 +1600,7 @@ std::unique_ptr QgsGeos::fromGeos( const GEOSGeometry *geos } case GEOS_MULTIPOINT: { - std::unique_ptr< QgsMultiPoint > multiPoint( new QgsMultiPoint() ); + auto multiPoint = std::make_unique(); int nParts = GEOSGetNumGeometries_r( context, geos ); multiPoint->reserve( nParts ); for ( int i = 0; i < nParts; ++i ) @@ -1618,7 +1618,7 @@ std::unique_ptr QgsGeos::fromGeos( const GEOSGeometry *geos } case GEOS_MULTILINESTRING: { - std::unique_ptr< QgsMultiLineString > multiLineString( new QgsMultiLineString() ); + auto multiLineString = std::make_unique(); int nParts = GEOSGetNumGeometries_r( context, geos ); multiLineString->reserve( nParts ); for ( int i = 0; i < nParts; ++i ) @@ -1633,7 +1633,7 @@ std::unique_ptr QgsGeos::fromGeos( const GEOSGeometry *geos } case GEOS_MULTIPOLYGON: { - std::unique_ptr< QgsMultiPolygon > multiPolygon( new QgsMultiPolygon() ); + auto multiPolygon = std::make_unique(); int nParts = GEOSGetNumGeometries_r( context, geos ); multiPolygon->reserve( nParts ); @@ -1649,7 +1649,7 @@ std::unique_ptr QgsGeos::fromGeos( const GEOSGeometry *geos } case GEOS_GEOMETRYCOLLECTION: { - std::unique_ptr< QgsGeometryCollection > geomCollection( new QgsGeometryCollection() ); + auto geomCollection = std::make_unique(); int nParts = GEOSGetNumGeometries_r( context, geos ); geomCollection->reserve( nParts ); for ( int i = 0; i < nParts; ++i ) @@ -1679,7 +1679,7 @@ std::unique_ptr QgsGeos::fromGeosPolygon( const GEOSGeometry *geos ) bool hasZ = ( nCoordDims == 3 ); bool hasM = ( ( nDims - nCoordDims ) == 1 ); - std::unique_ptr< QgsPolygon > polygon( new QgsPolygon() ); + auto polygon = std::make_unique(); const GEOSGeometry *ring = GEOSGetExteriorRing_r( context, geos ); if ( ring ) @@ -1740,7 +1740,7 @@ std::unique_ptr QgsGeos::sequenceToLinestring( const GEOSGeometry } } #endif - std::unique_ptr< QgsLineString > line( new QgsLineString( xOut, yOut, zOut, mOut ) ); + auto line = std::make_unique( xOut, yOut, zOut, mOut ); return line; } diff --git a/src/core/geometry/qgsmulticurve.cpp b/src/core/geometry/qgsmulticurve.cpp index 8bc46eeca26..bd48691a994 100644 --- a/src/core/geometry/qgsmulticurve.cpp +++ b/src/core/geometry/qgsmulticurve.cpp @@ -236,7 +236,7 @@ QgsMultiCurve *QgsMultiCurve::reversed() const QgsAbstractGeometry *QgsMultiCurve::boundary() const { - std::unique_ptr< QgsMultiPoint > multiPoint( new QgsMultiPoint() ); + auto multiPoint = std::make_unique(); multiPoint->reserve( mGeometries.size() * 2 ); for ( int i = 0; i < mGeometries.size(); ++i ) { diff --git a/src/core/geometry/qgsmultipolygon.cpp b/src/core/geometry/qgsmultipolygon.cpp index 70fe2fea0a5..8387bbad041 100644 --- a/src/core/geometry/qgsmultipolygon.cpp +++ b/src/core/geometry/qgsmultipolygon.cpp @@ -260,7 +260,7 @@ QgsMultiSurface *QgsMultiPolygon::toCurveType() const QgsAbstractGeometry *QgsMultiPolygon::boundary() const { - std::unique_ptr< QgsMultiLineString > multiLine( new QgsMultiLineString() ); + auto multiLine = std::make_unique(); multiLine->reserve( mGeometries.size() ); for ( int i = 0; i < mGeometries.size(); ++i ) { diff --git a/src/core/geometry/qgsmultisurface.cpp b/src/core/geometry/qgsmultisurface.cpp index 31b0be2ddf8..35d0031d9fe 100644 --- a/src/core/geometry/qgsmultisurface.cpp +++ b/src/core/geometry/qgsmultisurface.cpp @@ -221,7 +221,7 @@ bool QgsMultiSurface::insertGeometry( QgsAbstractGeometry *g, int index ) QgsAbstractGeometry *QgsMultiSurface::boundary() const { - std::unique_ptr< QgsMultiCurve > multiCurve( new QgsMultiCurve() ); + auto multiCurve = std::make_unique(); multiCurve->reserve( mGeometries.size() ); for ( int i = 0; i < mGeometries.size(); ++i ) { diff --git a/src/core/geometry/qgspolygon.cpp b/src/core/geometry/qgspolygon.cpp index 64a1a0d71ef..15f32f7eceb 100644 --- a/src/core/geometry/qgspolygon.cpp +++ b/src/core/geometry/qgspolygon.cpp @@ -101,7 +101,7 @@ bool QgsPolygon::fromWkb( QgsConstWkbPtr &wkbPtr ) wkbPtr >> nRings; for ( int i = 0; i < nRings; ++i ) { - std::unique_ptr< QgsLineString > line( new QgsLineString() ); + auto line = std::make_unique(); line->fromWkbPoints( ringType, wkbPtr ); /*if ( !line->isRing() ) { diff --git a/src/core/geometry/qgspolyhedralsurface.cpp b/src/core/geometry/qgspolyhedralsurface.cpp index 005c78dec5c..2d2eb74b131 100644 --- a/src/core/geometry/qgspolyhedralsurface.cpp +++ b/src/core/geometry/qgspolyhedralsurface.cpp @@ -375,7 +375,7 @@ double QgsPolyhedralSurface::perimeter() const QgsAbstractGeometry *QgsPolyhedralSurface::boundary() const { - std::unique_ptr< QgsMultiLineString > multiLine( new QgsMultiLineString() ); + auto multiLine = std::make_unique(); multiLine->reserve( mPatches.size() ); for ( QgsPolygon *polygon : mPatches ) { diff --git a/src/core/geometry/qgsregularpolygon.cpp b/src/core/geometry/qgsregularpolygon.cpp index 28f2883ad20..1cb49408146 100644 --- a/src/core/geometry/qgsregularpolygon.cpp +++ b/src/core/geometry/qgsregularpolygon.cpp @@ -182,7 +182,7 @@ QgsPointSequence QgsRegularPolygon::points() const QgsPolygon *QgsRegularPolygon::toPolygon() const { - std::unique_ptr polygon( new QgsPolygon() ); + auto polygon = std::make_unique(); if ( isEmpty() ) { return polygon.release(); @@ -195,7 +195,7 @@ QgsPolygon *QgsRegularPolygon::toPolygon() const QgsLineString *QgsRegularPolygon::toLineString() const { - std::unique_ptr ext( new QgsLineString() ); + auto ext = std::make_unique(); if ( isEmpty() ) { return ext.release(); diff --git a/src/core/geometry/qgstriangle.cpp b/src/core/geometry/qgstriangle.cpp index 2b758c521d1..d134f133e2b 100644 --- a/src/core/geometry/qgstriangle.cpp +++ b/src/core/geometry/qgstriangle.cpp @@ -251,7 +251,7 @@ QgsPolygon *QgsTriangle::surfaceToPolygon() const QgsCurvePolygon *QgsTriangle::toCurveType() const { - std::unique_ptr curvePolygon( new QgsCurvePolygon() ); + auto curvePolygon = std::make_unique(); curvePolygon->setExteriorRing( mExteriorRing->clone() ); return curvePolygon.release(); diff --git a/src/core/gps/qgsgpslogger.cpp b/src/core/gps/qgsgpslogger.cpp index 64140690092..5d2598c5dc3 100644 --- a/src/core/gps/qgsgpslogger.cpp +++ b/src/core/gps/qgsgpslogger.cpp @@ -153,7 +153,7 @@ QgsGeometry QgsGpsLogger::currentGeometry( Qgis::WkbType type, QString &error ) { QgsGeometry g; - std::unique_ptr ringWgs84( new QgsLineString( captureListWgs84 ) ); + auto ringWgs84 = std::make_unique( captureListWgs84 ); if ( !is3D ) ringWgs84->dropZValue(); if ( !isMeasure ) @@ -168,7 +168,7 @@ QgsGeometry QgsGpsLogger::currentGeometry( Qgis::WkbType type, QString &error ) else if ( geometryType == Qgis::GeometryType::Polygon ) { ringWgs84->close(); - std::unique_ptr polygon( new QgsPolygon() ); + auto polygon = std::make_unique(); polygon->setExteriorRing( ringWgs84.release() ); g = QgsGeometry( polygon.release() ); diff --git a/src/core/layout/qgscompositionconverter.cpp b/src/core/layout/qgscompositionconverter.cpp index 7b675c92ada..710fed0228e 100644 --- a/src/core/layout/qgscompositionconverter.cpp +++ b/src/core/layout/qgscompositionconverter.cpp @@ -936,7 +936,7 @@ bool QgsCompositionConverter::readMapXml( QgsLayoutItemMap *layoutItem, const QD for ( int i = 0; i < mapOverviewNodeList.size(); ++i ) { const QDomElement mapOverviewElem = mapOverviewNodeList.at( i ).toElement(); - std::unique_ptr mapOverview( new QgsLayoutItemMapOverview( mapOverviewElem.attribute( QStringLiteral( "name" ) ), layoutItem ) ); + auto mapOverview = std::make_unique( mapOverviewElem.attribute( QStringLiteral( "name" ) ), layoutItem ); mapOverview->readXml( mapOverviewElem, doc, context ); const QString frameMapId = mapOverviewElem.attribute( QStringLiteral( "frameMap" ), QStringLiteral( "-1" ) ); if ( frameMapId != QLatin1String( "-1" ) && mapId2Uuid.contains( frameMapId ) ) diff --git a/src/core/layout/qgslayout.cpp b/src/core/layout/qgslayout.cpp index 8a8f2f80ded..ba305b947d3 100644 --- a/src/core/layout/qgslayout.cpp +++ b/src/core/layout/qgslayout.cpp @@ -768,7 +768,7 @@ QgsLayoutItemGroup *QgsLayout::groupItems( const QList &items ) } mUndoStack->beginMacro( tr( "Group Items" ) ); - std::unique_ptr< QgsLayoutItemGroup > itemGroup( new QgsLayoutItemGroup( this ) ); + auto itemGroup = std::make_unique( this ); for ( QgsLayoutItem *item : items ) { itemGroup->addItem( item ); @@ -776,7 +776,7 @@ QgsLayoutItemGroup *QgsLayout::groupItems( const QList &items ) QgsLayoutItemGroup *returnGroup = itemGroup.get(); addLayoutItem( itemGroup.release() ); - std::unique_ptr< QgsLayoutItemGroupUndoCommand > c( new QgsLayoutItemGroupUndoCommand( QgsLayoutItemGroupUndoCommand::Grouped, returnGroup, this, tr( "Group Items" ) ) ); + auto c = std::make_unique( QgsLayoutItemGroupUndoCommand::Grouped, returnGroup, this, tr( "Group Items" ) ); mUndoStack->push( c.release() ); mProject->setDirty( true ); @@ -797,7 +797,7 @@ QList QgsLayout::ungroupItems( QgsLayoutItemGroup *group ) mUndoStack->beginMacro( tr( "Ungroup Items" ) ); // Call this before removing group items so it can keep note // of contents - std::unique_ptr< QgsLayoutItemGroupUndoCommand > c( new QgsLayoutItemGroupUndoCommand( QgsLayoutItemGroupUndoCommand::Ungrouped, group, this, tr( "Ungroup Items" ) ) ); + auto c = std::make_unique( QgsLayoutItemGroupUndoCommand::Ungrouped, group, this, tr( "Ungroup Items" ) ); mUndoStack->push( c.release() ); mProject->setDirty( true ); diff --git a/src/core/layout/qgslayoutguidecollection.cpp b/src/core/layout/qgslayoutguidecollection.cpp index 736f3f93950..8a9cd00d90a 100644 --- a/src/core/layout/qgslayoutguidecollection.cpp +++ b/src/core/layout/qgslayoutguidecollection.cpp @@ -457,7 +457,7 @@ void QgsLayoutGuideCollection::applyGuidesToAllOtherPages( int sourcePage ) if ( p == sourcePage ) continue; - std::unique_ptr< QgsLayoutGuide> newGuide( new QgsLayoutGuide( guide->orientation(), guide->position(), mPageCollection->page( p ) ) ); + auto newGuide = std::make_unique( guide->orientation(), guide->position(), mPageCollection->page( p ) ); newGuide->setLayout( mLayout ); if ( newGuide->item()->isVisible() ) { @@ -579,7 +579,7 @@ bool QgsLayoutGuideCollection::readXml( const QDomElement &e, const QDomDocument double pos = element.attribute( QStringLiteral( "position" ), QStringLiteral( "0" ) ).toDouble(); Qgis::LayoutUnit unit = QgsUnitTypes::decodeLayoutUnit( element.attribute( QStringLiteral( "units" ) ) ); int page = element.attribute( QStringLiteral( "page" ), QStringLiteral( "0" ) ).toInt(); - std::unique_ptr< QgsLayoutGuide > guide( new QgsLayoutGuide( orientation, QgsLayoutMeasurement( pos, unit ), mPageCollection->page( page ) ) ); + auto guide = std::make_unique( orientation, QgsLayoutMeasurement( pos, unit ), mPageCollection->page( page ) ); guide->update(); addGuide( guide.release() ); } diff --git a/src/core/layout/qgslayoutpagecollection.cpp b/src/core/layout/qgslayoutpagecollection.cpp index b388be0b78f..0626427f131 100644 --- a/src/core/layout/qgslayoutpagecollection.cpp +++ b/src/core/layout/qgslayoutpagecollection.cpp @@ -418,7 +418,7 @@ bool QgsLayoutPageCollection::readXml( const QDomElement &e, const QDomDocument for ( int i = 0; i < pageList.size(); ++i ) { QDomElement pageElement = pageList.at( i ).toElement(); - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( mLayout ) ); + auto page = std::make_unique( mLayout ); if ( mPageStyleSymbol ) page->setPageStyleSymbol( mPageStyleSymbol->clone() ); page->readXml( pageElement, document, context ); diff --git a/src/core/mesh/qgsmeshadvancedediting.cpp b/src/core/mesh/qgsmeshadvancedediting.cpp index 9acadd881ae..3ee47b15fa4 100644 --- a/src/core/mesh/qgsmeshadvancedediting.cpp +++ b/src/core/mesh/qgsmeshadvancedediting.cpp @@ -433,7 +433,7 @@ bool QgsMeshEditRefineFaces::createNewBorderFaces( QgsMeshEditor *meshEditor, try { - std::unique_ptr cdt( new p2t::CDT( points ) ); + auto cdt = std::make_unique( points ); cdt->Triangulate(); std::vector triangles = cdt->GetTriangles(); QVector faces( triangles.size() ); diff --git a/src/core/mesh/qgsmeshforcebypolylines.cpp b/src/core/mesh/qgsmeshforcebypolylines.cpp index 46edfb588a4..c9593d4ea64 100644 --- a/src/core/mesh/qgsmeshforcebypolylines.cpp +++ b/src/core/mesh/qgsmeshforcebypolylines.cpp @@ -906,7 +906,7 @@ bool QgsMeshEditForceByLine::triangulateHoles( mapPoly2TriPointToVertex.insert( holeToFill[i + hole.count()], vertexLocalIndex + mesh->vertexCount() ); } - std::unique_ptr cdt( new p2t::CDT( holeToFill ) ); + auto cdt = std::make_unique( holeToFill ); cdt->Triangulate(); std::vector triangles = cdt->GetTriangles(); QVector newFaces( triangles.size() ); diff --git a/src/core/mesh/qgsmeshlayerinterpolator.cpp b/src/core/mesh/qgsmeshlayerinterpolator.cpp index f2581c479ea..ce6c6595f2b 100644 --- a/src/core/mesh/qgsmeshlayerinterpolator.cpp +++ b/src/core/mesh/qgsmeshlayerinterpolator.cpp @@ -72,7 +72,7 @@ int QgsMeshLayerInterpolator::bandCount() const QgsRasterBlock *QgsMeshLayerInterpolator::block( int, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback ) { - std::unique_ptr outputBlock( new QgsRasterBlock( Qgis::DataType::Float64, width, height ) ); + auto outputBlock = std::make_unique( Qgis::DataType::Float64, width, height ); const double noDataValue = std::numeric_limits::quiet_NaN(); outputBlock->setNoDataValue( noDataValue ); outputBlock->setIsNoData(); // assume initially that all values are unset diff --git a/src/core/mesh/qgstopologicalmesh.cpp b/src/core/mesh/qgstopologicalmesh.cpp index c5fa7f5ff3c..b65069e29bb 100644 --- a/src/core/mesh/qgstopologicalmesh.cpp +++ b/src/core/mesh/qgstopologicalmesh.cpp @@ -1361,7 +1361,7 @@ QgsTopologicalMesh::Changes QgsTopologicalMesh::removeVertexFillHole( int vertex mapPoly2TriPointToVertex.insert( holeToFill[i], holeVertices.at( i ) ); } - std::unique_ptr cdt( new p2t::CDT( holeToFill ) ); + auto cdt = std::make_unique( holeToFill ); cdt->Triangulate(); std::vector triangles = cdt->GetTriangles(); @@ -2398,7 +2398,7 @@ QgsTopologicalMesh::Changes QgsTopologicalMesh::insertVertexInFacesEdge( int fac mapPoly2TriPointToVertex.insert( faceToFill[i], newBoundary.at( i ) ); } - std::unique_ptr cdt( new p2t::CDT( faceToFill ) ); + auto cdt = std::make_unique( faceToFill ); cdt->Triangulate(); std::vector triangles = cdt->GetTriangles(); QVector newFaces( triangles.size() ); diff --git a/src/core/processing/models/qgsprocessingmodelalgorithm.cpp b/src/core/processing/models/qgsprocessingmodelalgorithm.cpp index 3e9fe7da2e9..8cf16f42a65 100644 --- a/src/core/processing/models/qgsprocessingmodelalgorithm.cpp +++ b/src/core/processing/models/qgsprocessingmodelalgorithm.cpp @@ -1312,7 +1312,7 @@ QMap QgsProcessingMode QgsExpressionContextScope *QgsProcessingModelAlgorithm::createExpressionContextScopeForChildAlgorithm( const QString &childId, QgsProcessingContext &context, const QVariantMap &modelParameters, const QVariantMap &results ) const { - std::unique_ptr< QgsExpressionContextScope > scope( new QgsExpressionContextScope( QStringLiteral( "algorithm_inputs" ) ) ); + auto scope = std::make_unique( QStringLiteral( "algorithm_inputs" ) ); QMap< QString, QgsProcessingModelAlgorithm::VariableDefinition> variables = variablesForChildAlgorithm( childId, &context, modelParameters, results ); QMap< QString, QgsProcessingModelAlgorithm::VariableDefinition>::const_iterator varIt = variables.constBegin(); for ( ; varIt != variables.constEnd(); ++varIt ) diff --git a/src/core/processing/qgsprocessingutils.cpp b/src/core/processing/qgsprocessingutils.cpp index a08ca30bb21..091f13e6a0a 100644 --- a/src/core/processing/qgsprocessingutils.cpp +++ b/src/core/processing/qgsprocessingutils.cpp @@ -1011,7 +1011,7 @@ QgsFeatureSink *QgsProcessingUtils::createFeatureSink( QString &destination, Qgs destination = layer->id(); // this is a factory, so we need to return a proxy - std::unique_ptr< QgsProcessingFeatureSink > sink( new QgsProcessingFeatureSink( layer->dataProvider(), destination, context ) ); + auto sink = std::make_unique( layer->dataProvider(), destination, context ); context.temporaryLayerStore()->addMapLayer( layer.release() ); return sink.release(); diff --git a/src/core/project/qgsproject.cpp b/src/core/project/qgsproject.cpp index be8e457949d..6965cefe241 100644 --- a/src/core/project/qgsproject.cpp +++ b/src/core/project/qgsproject.cpp @@ -1991,7 +1991,7 @@ bool QgsProject::read( Qgis::ProjectReadFlags flags ) const QString attachmentsZip = finfo.absoluteDir().absoluteFilePath( QStringLiteral( "%1_attachments.zip" ).arg( finfo.completeBaseName() ) ); if ( QFile( attachmentsZip ).exists() ) { - std::unique_ptr archive( new QgsArchive() ); + auto archive = std::make_unique(); if ( archive->unzip( attachmentsZip ) ) { releaseHandlesToProjectArchive(); @@ -2040,7 +2040,7 @@ bool QgsProject::readProjectFile( const QString &filename, Qgis::ProjectReadFlag } profile.switchTask( tr( "Reading project file" ) ); - std::unique_ptr doc( new QDomDocument( QStringLiteral( "qgis" ) ) ); + auto doc = std::make_unique( QStringLiteral( "qgis" ) ); if ( !projectFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) { @@ -3248,7 +3248,7 @@ bool QgsProject::writeProjectFile( const QString &filename ) const QDomDocumentType documentType = QDomImplementation().createDocumentType( QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); - std::unique_ptr doc( new QDomDocument( documentType ) ); + auto doc = std::make_unique( documentType ); QDomElement qgisNode = doc->createElement( QStringLiteral( "qgis" ) ); qgisNode.setAttribute( QStringLiteral( "projectname" ), title() ); @@ -4596,7 +4596,7 @@ bool QgsProject::unzip( const QString &filename, Qgis::ProjectReadFlags flags ) QGIS_PROTECT_QOBJECT_THREAD_ACCESS clearError(); - std::unique_ptr archive( new QgsProjectArchive() ); + auto archive = std::make_unique(); // unzip the archive if ( !archive->unzip( filename ) ) @@ -4648,7 +4648,7 @@ bool QgsProject::zip( const QString &filename ) clearError(); // save the current project in a temporary .qgs file - std::unique_ptr archive( new QgsProjectArchive() ); + auto archive = std::make_unique(); const QString baseName = QFileInfo( filename ).baseName(); const QString qgsFileName = QStringLiteral( "%1.qgs" ).arg( baseName ); QFile qgsFile( QDir( archive->dir() ).filePath( qgsFileName ) ); diff --git a/src/core/providers/qgsproviderregistry.cpp b/src/core/providers/qgsproviderregistry.cpp index 2f026da2d62..d5b9412aa1b 100644 --- a/src/core/providers/qgsproviderregistry.cpp +++ b/src/core/providers/qgsproviderregistry.cpp @@ -913,7 +913,7 @@ QLibrary *QgsProviderRegistry::createProviderLibrary( QString const &providerKey if ( lib.isEmpty() ) return nullptr; - std::unique_ptr< QLibrary > myLib( new QLibrary( lib ) ); + auto myLib = std::make_unique( lib ); QgsDebugMsgLevel( "Library name is " + myLib->fileName(), 2 ); diff --git a/src/core/qgselevationmap.cpp b/src/core/qgselevationmap.cpp index 762b2f9f500..c24bd1aa0ae 100644 --- a/src/core/qgselevationmap.cpp +++ b/src/core/qgselevationmap.cpp @@ -58,7 +58,7 @@ float QgsElevationMap::decodeElevation( QRgb colorRaw ) std::unique_ptr QgsElevationMap::fromRasterBlock( QgsRasterBlock *block ) { - std::unique_ptr elevMap( new QgsElevationMap( QSize( block->width(), block->height() ) ) ); + auto elevMap = std::make_unique( QSize( block->width(), block->height() ) ); QRgb *dataPtr = reinterpret_cast( elevMap->mElevationImage.bits() ); for ( int row = 0; row < block->height(); ++row ) { diff --git a/src/core/qgsmaptopixelgeometrysimplifier.cpp b/src/core/qgsmaptopixelgeometrysimplifier.cpp index d948b471092..4e743f67960 100644 --- a/src/core/qgsmaptopixelgeometrysimplifier.cpp +++ b/src/core/qgsmaptopixelgeometrysimplifier.cpp @@ -376,7 +376,7 @@ std::unique_ptr< QgsAbstractGeometry > QgsMapToPixelSimplifier::simplifyGeometry else if ( flatType == Qgis::WkbType::Polygon ) { const QgsPolygon &srcPolygon = dynamic_cast( geometry ); - std::unique_ptr polygon( new QgsPolygon() ); + auto polygon = std::make_unique(); std::unique_ptr extRing = simplifyGeometry( simplifyFlags, simplifyAlgorithm, *srcPolygon.exteriorRing(), map2pixelTol, true ); polygon->setExteriorRing( qgsgeometry_cast( extRing.release() ) ); for ( int i = 0; i < srcPolygon.numInteriorRings(); ++i ) diff --git a/src/core/qgsogcutils.cpp b/src/core/qgsogcutils.cpp index 16a3d25f3e1..d9bf029f119 100644 --- a/src/core/qgsogcutils.cpp +++ b/src/core/qgsogcutils.cpp @@ -3526,7 +3526,7 @@ QgsExpressionNodeFunction *QgsOgcUtilsExpressionFromFilter::nodeSpatialOperatorF // we are exploiting the fact that our function names are the same as the XML tag names const int opIdx = QgsExpression::functionIndex( element.tagName().toLower() ); - std::unique_ptr gml2Args( new QgsExpressionNode::NodeList() ); + auto gml2Args = std::make_unique(); QDomElement childElem = element.firstChildElement(); QString gml2Str; while ( !childElem.isNull() && gml2Str.isEmpty() ) @@ -3548,7 +3548,7 @@ QgsExpressionNodeFunction *QgsOgcUtilsExpressionFromFilter::nodeSpatialOperatorF return nullptr; } - std::unique_ptr opArgs( new QgsExpressionNode::NodeList() ); + auto opArgs = std::make_unique(); opArgs->append( new QgsExpressionNodeFunction( QgsExpression::functionIndex( QStringLiteral( "$geometry" ) ), new QgsExpressionNode::NodeList() ) ); opArgs->append( new QgsExpressionNodeFunction( QgsExpression::functionIndex( QStringLiteral( "geomFromGML" ) ), gml2Args.release() ) ); @@ -3706,7 +3706,7 @@ QgsExpressionNodeFunction *QgsOgcUtilsExpressionFromFilter::nodeFunctionFromOgcF if ( element.attribute( QStringLiteral( "name" ) ) != funcDef->name() ) continue; - std::unique_ptr args( new QgsExpressionNode::NodeList() ); + auto args = std::make_unique(); QDomElement operandElem = element.firstChildElement(); while ( !operandElem.isNull() ) diff --git a/src/core/qgstessellator.cpp b/src/core/qgstessellator.cpp index 6811b0bcbb8..67f14843901 100644 --- a/src/core/qgstessellator.cpp +++ b/src/core/qgstessellator.cpp @@ -680,7 +680,7 @@ void QgsTessellator::addPolygon( const QgsPolygon &polygon, float extrusionHeigh _ringToPoly2tri( qgsgeometry_cast< const QgsLineString * >( polygonNew->exteriorRing() ), polyline, mNoZ ? nullptr : &z ); polylinesToDelete << polyline; - std::unique_ptr cdt( new p2t::CDT( polyline ) ); + auto cdt = std::make_unique( polyline ); // polygon holes for ( int i = 0; i < polygonNew->numInteriorRings(); ++i ) diff --git a/src/core/raster/qgsbrightnesscontrastfilter.cpp b/src/core/raster/qgsbrightnesscontrastfilter.cpp index 469d9d98c1b..9d6dbc2a202 100644 --- a/src/core/raster/qgsbrightnesscontrastfilter.cpp +++ b/src/core/raster/qgsbrightnesscontrastfilter.cpp @@ -108,7 +108,7 @@ QgsRasterBlock *QgsBrightnessContrastFilter::block( int bandNo, QgsRectangle co Q_UNUSED( bandNo ) QgsDebugMsgLevel( QStringLiteral( "width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.toString() ), 4 ); - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput ) { return outputBlock.release(); diff --git a/src/core/raster/qgshillshaderenderer.cpp b/src/core/raster/qgshillshaderenderer.cpp index 0b39b7a590c..00349b08f63 100644 --- a/src/core/raster/qgshillshaderenderer.cpp +++ b/src/core/raster/qgshillshaderenderer.cpp @@ -99,7 +99,7 @@ void QgsHillshadeRenderer::writeXml( QDomDocument &doc, QDomElement &parentElem QgsRasterBlock *QgsHillshadeRenderer::block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback ) { Q_UNUSED( bandNo ) - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput ) { QgsDebugError( QStringLiteral( "No input raster!" ) ); diff --git a/src/core/raster/qgshuesaturationfilter.cpp b/src/core/raster/qgshuesaturationfilter.cpp index 465f3e2672d..676eba155af 100644 --- a/src/core/raster/qgshuesaturationfilter.cpp +++ b/src/core/raster/qgshuesaturationfilter.cpp @@ -113,7 +113,7 @@ QgsRasterBlock *QgsHueSaturationFilter::block( int bandNo, QgsRectangle const & Q_UNUSED( bandNo ) QgsDebugMsgLevel( QStringLiteral( "width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.toString() ), 4 ); - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput ) { return outputBlock.release(); diff --git a/src/core/raster/qgsmultibandcolorrenderer.cpp b/src/core/raster/qgsmultibandcolorrenderer.cpp index 584c61f54db..f75957c74d2 100644 --- a/src/core/raster/qgsmultibandcolorrenderer.cpp +++ b/src/core/raster/qgsmultibandcolorrenderer.cpp @@ -139,7 +139,7 @@ QgsRasterRenderer *QgsMultiBandColorRenderer::create( const QDomElement &elem, Q QgsRasterBlock *QgsMultiBandColorRenderer::block( int bandNo, QgsRectangle const &extent, int width, int height, QgsRasterBlockFeedback *feedback ) { Q_UNUSED( bandNo ) - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput ) { return outputBlock.release(); diff --git a/src/core/raster/qgspalettedrasterrenderer.cpp b/src/core/raster/qgspalettedrasterrenderer.cpp index 1fedf3c751c..4050b5c3e0c 100644 --- a/src/core/raster/qgspalettedrasterrenderer.cpp +++ b/src/core/raster/qgspalettedrasterrenderer.cpp @@ -208,7 +208,7 @@ bool QgsPalettedRasterRenderer::setInputBand( int band ) QgsRasterBlock *QgsPalettedRasterRenderer::block( int, QgsRectangle const &extent, int width, int height, QgsRasterBlockFeedback *feedback ) { - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput || mMultiValueClassData.isEmpty() ) { return outputBlock.release(); diff --git a/src/core/raster/qgsrastercontourrenderer.cpp b/src/core/raster/qgsrastercontourrenderer.cpp index bbea2067fc1..786a8a54211 100644 --- a/src/core/raster/qgsrastercontourrenderer.cpp +++ b/src/core/raster/qgsrastercontourrenderer.cpp @@ -145,7 +145,7 @@ QgsRasterBlock *QgsRasterContourRenderer::block( int bandNo, const QgsRectangle { Q_UNUSED( bandNo ) - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput || !mContourSymbol ) { return outputBlock.release(); diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp index 811d5914bd1..05d62ab54e9 100644 --- a/src/core/raster/qgsrasterlayer.cpp +++ b/src/core/raster/qgsrasterlayer.cpp @@ -1419,7 +1419,7 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh if ( myBand != -1 ) { const Qgis::DataType myType = static_cast< Qgis::DataType >( mDataProvider->dataType( myBand ) ); - std::unique_ptr myEnhancement( new QgsContrastEnhancement( static_cast< Qgis::DataType >( myType ) ) ); + auto myEnhancement = std::make_unique( static_cast< Qgis::DataType >( myType ) ); myEnhancement->setContrastEnhancementAlgorithm( algorithm, generateLookupTableFlag ); double min; diff --git a/src/core/raster/qgsrasternuller.cpp b/src/core/raster/qgsrasternuller.cpp index 65580ddb8f6..ac61c261c09 100644 --- a/src/core/raster/qgsrasternuller.cpp +++ b/src/core/raster/qgsrasternuller.cpp @@ -85,7 +85,7 @@ QgsRasterBlock *QgsRasterNuller::block( int bandNo, QgsRectangle const &extent, return inputBlock.release(); } - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock( inputBlock->dataType(), width, height ) ); + auto outputBlock = std::make_unique( inputBlock->dataType(), width, height ); if ( mHasOutputNoData.value( bandNo - 1 ) || inputBlock->hasNoDataValue() ) { double noDataValue; diff --git a/src/core/raster/qgsrasterresamplefilter.cpp b/src/core/raster/qgsrasterresamplefilter.cpp index 72a10578d63..7991d8cce12 100644 --- a/src/core/raster/qgsrasterresamplefilter.cpp +++ b/src/core/raster/qgsrasterresamplefilter.cpp @@ -123,7 +123,7 @@ QgsRasterBlock *QgsRasterResampleFilter::block( int bandNo, QgsRectangle const const int bandNumber = 1; QgsDebugMsgLevel( QStringLiteral( "width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.toString() ), 4 ); - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput ) return outputBlock.release(); diff --git a/src/core/raster/qgsrastersinglecolorrenderer.cpp b/src/core/raster/qgsrastersinglecolorrenderer.cpp index bf2f6414c3c..433d1478393 100644 --- a/src/core/raster/qgsrastersinglecolorrenderer.cpp +++ b/src/core/raster/qgsrastersinglecolorrenderer.cpp @@ -60,7 +60,7 @@ QgsRasterBlock *QgsRasterSingleColorRenderer::block( int, const QgsRectangle &ex { QgsDebugMsgLevel( QStringLiteral( "width = %1 height = %2" ).arg( width ).arg( height ), 4 ); - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput || mInputBand == -1 ) { return outputBlock.release(); diff --git a/src/core/raster/qgssinglebandcolordatarenderer.cpp b/src/core/raster/qgssinglebandcolordatarenderer.cpp index e9ed71cfa46..a23e9936b74 100644 --- a/src/core/raster/qgssinglebandcolordatarenderer.cpp +++ b/src/core/raster/qgssinglebandcolordatarenderer.cpp @@ -59,7 +59,7 @@ QgsRasterBlock *QgsSingleBandColorDataRenderer::block( int bandNo, QgsRectangle { Q_UNUSED( bandNo ) - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput ) { return outputBlock.release(); diff --git a/src/core/raster/qgssinglebandgrayrenderer.cpp b/src/core/raster/qgssinglebandgrayrenderer.cpp index 3011f695fea..54b17d14d66 100644 --- a/src/core/raster/qgssinglebandgrayrenderer.cpp +++ b/src/core/raster/qgssinglebandgrayrenderer.cpp @@ -99,7 +99,7 @@ QgsRasterBlock *QgsSingleBandGrayRenderer::block( int bandNo, const QgsRectangle Q_UNUSED( bandNo ) QgsDebugMsgLevel( QStringLiteral( "width = %1 height = %2" ).arg( width ).arg( height ), 4 ); - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput ) { return outputBlock.release(); diff --git a/src/core/raster/qgssinglebandpseudocolorrenderer.cpp b/src/core/raster/qgssinglebandpseudocolorrenderer.cpp index e203fd2aa03..13ce0da1f5f 100644 --- a/src/core/raster/qgssinglebandpseudocolorrenderer.cpp +++ b/src/core/raster/qgssinglebandpseudocolorrenderer.cpp @@ -210,7 +210,7 @@ QgsRasterBlock *QgsSingleBandPseudoColorRenderer::block( int bandNo, QgsRectangl { Q_UNUSED( bandNo ) - std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() ); + auto outputBlock = std::make_unique(); if ( !mInput || !mShader || !mShader->rasterShaderFunction() ) { return outputBlock.release(); diff --git a/src/core/symbology/qgsfillsymbollayer.cpp b/src/core/symbology/qgsfillsymbollayer.cpp index d335825401a..5c8cd805e66 100644 --- a/src/core/symbology/qgsfillsymbollayer.cpp +++ b/src/core/symbology/qgsfillsymbollayer.cpp @@ -5006,7 +5006,7 @@ QgsSymbolLayer *QgsCentroidFillSymbolLayer::createFromSld( QDomElement &element QgsSymbolLayerList layers; layers.append( l ); - std::unique_ptr< QgsMarkerSymbol > marker( new QgsMarkerSymbol( layers ) ); + auto marker = std::make_unique( layers ); auto sl = std::make_unique< QgsCentroidFillSymbolLayer >(); sl->setSubSymbol( marker.release() ); diff --git a/src/core/vector/qgsvectorlayerexporter.cpp b/src/core/vector/qgsvectorlayerexporter.cpp index 1c8feb6488e..4a6ee452508 100644 --- a/src/core/vector/qgsvectorlayerexporter.cpp +++ b/src/core/vector/qgsvectorlayerexporter.cpp @@ -537,7 +537,7 @@ QgsVectorLayerExporterTask::QgsVectorLayerExporterTask( QgsVectorLayer *layer, c QgsVectorLayerExporterTask *QgsVectorLayerExporterTask::withLayerOwnership( QgsVectorLayer *layer, const QString &uri, const QString &providerKey, const QgsCoordinateReferenceSystem &destinationCrs, const QMap &options ) { - std::unique_ptr< QgsVectorLayerExporterTask > newTask( new QgsVectorLayerExporterTask( layer, uri, providerKey, destinationCrs, options ) ); + auto newTask = std::make_unique( layer, uri, providerKey, destinationCrs, options ); newTask->mOwnsLayer = true; return newTask.release(); } diff --git a/src/core/vectortile/qgsvectortilemvtdecoder.cpp b/src/core/vectortile/qgsvectortilemvtdecoder.cpp index 7148bdcade6..a3fb0dbe069 100644 --- a/src/core/vectortile/qgsvectortilemvtdecoder.cpp +++ b/src/core/vectortile/qgsvectortilemvtdecoder.cpp @@ -309,7 +309,7 @@ QgsVectorTileFeatures QgsVectorTileMVTDecoder::layerFeatures( const QMap ring( new QgsLineString( tmpPoints ) ); + auto ring = std::make_unique( tmpPoints ); tmpPoints.clear(); if ( QgsVectorTileMVTUtils::isExteriorRing( ring.get() ) ) diff --git a/src/gui/layout/qgslayoutguidewidget.cpp b/src/gui/layout/qgslayoutguidewidget.cpp index 3cffb772ae3..97683fc52a7 100644 --- a/src/gui/layout/qgslayoutguidewidget.cpp +++ b/src/gui/layout/qgslayoutguidewidget.cpp @@ -68,13 +68,13 @@ QgsLayoutGuideWidget::QgsLayoutGuideWidget( QWidget *parent, QgsLayout *layout, void QgsLayoutGuideWidget::addHorizontalGuide() { - std::unique_ptr newGuide( new QgsLayoutGuide( Qt::Horizontal, QgsLayoutMeasurement( 0 ), mLayout->pageCollection()->page( mPage ) ) ); + auto newGuide = std::make_unique( Qt::Horizontal, QgsLayoutMeasurement( 0 ), mLayout->pageCollection()->page( mPage ) ); mLayout->guides().addGuide( newGuide.release() ); } void QgsLayoutGuideWidget::addVerticalGuide() { - std::unique_ptr newGuide( new QgsLayoutGuide( Qt::Vertical, QgsLayoutMeasurement( 0 ), mLayout->pageCollection()->page( mPage ) ) ); + auto newGuide = std::make_unique( Qt::Vertical, QgsLayoutMeasurement( 0 ), mLayout->pageCollection()->page( mPage ) ); mLayout->guides().addGuide( newGuide.release() ); } diff --git a/src/gui/layout/qgslayoutview.cpp b/src/gui/layout/qgslayoutview.cpp index 9b5326f17ac..729bb75982f 100644 --- a/src/gui/layout/qgslayoutview.cpp +++ b/src/gui/layout/qgslayoutview.cpp @@ -930,7 +930,7 @@ void QgsLayoutView::mousePressEvent( QMouseEvent *event ) if ( mTool ) { - std::unique_ptr me( new QgsLayoutViewMouseEvent( this, event, mTool->flags() & QgsLayoutViewTool::FlagSnaps ) ); + auto me = std::make_unique( this, event, mTool->flags() & QgsLayoutViewTool::FlagSnaps ); mTool->layoutPressEvent( me.get() ); event->setAccepted( me->isAccepted() ); } @@ -966,7 +966,7 @@ void QgsLayoutView::mouseReleaseEvent( QMouseEvent *event ) if ( mTool ) { - std::unique_ptr me( new QgsLayoutViewMouseEvent( this, event, mTool->flags() & QgsLayoutViewTool::FlagSnaps ) ); + auto me = std::make_unique( this, event, mTool->flags() & QgsLayoutViewTool::FlagSnaps ); mTool->layoutReleaseEvent( me.get() ); event->setAccepted( me->isAccepted() ); } @@ -985,7 +985,7 @@ void QgsLayoutView::mouseMoveEvent( QMouseEvent *event ) QPointF cursorPos = mapToScene( mMouseCurrentXY ); if ( mTool ) { - std::unique_ptr me( new QgsLayoutViewMouseEvent( this, event, false ) ); + auto me = std::make_unique( this, event, false ); if ( mTool->flags() & QgsLayoutViewTool::FlagSnaps ) { me->snapPoint( mHorizontalSnapLine, mVerticalSnapLine, mTool->ignoredSnapItems() ); @@ -1025,7 +1025,7 @@ void QgsLayoutView::mouseDoubleClickEvent( QMouseEvent *event ) if ( mTool ) { - std::unique_ptr me( new QgsLayoutViewMouseEvent( this, event, mTool->flags() & QgsLayoutViewTool::FlagSnaps ) ); + auto me = std::make_unique( this, event, mTool->flags() & QgsLayoutViewTool::FlagSnaps ); mTool->layoutDoubleClickEvent( me.get() ); event->setAccepted( me->isAccepted() ); } @@ -1244,7 +1244,7 @@ void QgsLayoutView::wheelZoom( QWheelEvent *event ) QGraphicsLineItem *QgsLayoutView::createSnapLine() const { - std::unique_ptr item( new QGraphicsLineItem( nullptr ) ); + auto item = std::make_unique( nullptr ); QPen pen = QPen( QColor( Qt::blue ) ); pen.setStyle( Qt::DotLine ); pen.setWidthF( 0.0 ); diff --git a/src/gui/plot/qgsplotcanvas.cpp b/src/gui/plot/qgsplotcanvas.cpp index d9a4f46f590..68087e65eee 100644 --- a/src/gui/plot/qgsplotcanvas.cpp +++ b/src/gui/plot/qgsplotcanvas.cpp @@ -140,7 +140,7 @@ void QgsPlotCanvas::mouseDoubleClickEvent( QMouseEvent *event ) { if ( mTool ) { - std::unique_ptr me( new QgsPlotMouseEvent( this, event ) ); + auto me = std::make_unique( this, event ); mTool->plotDoubleClickEvent( me.get() ); event->setAccepted( me->isAccepted() ); } @@ -153,7 +153,7 @@ void QgsPlotCanvas::mousePressEvent( QMouseEvent *event ) { if ( mTool ) { - std::unique_ptr me( new QgsPlotMouseEvent( this, event ) ); + auto me = std::make_unique( this, event ); mTool->plotPressEvent( me.get() ); event->setAccepted( me->isAccepted() ); } @@ -168,7 +168,7 @@ void QgsPlotCanvas::mousePressEvent( QMouseEvent *event ) } else if ( event->button() == Qt::RightButton && mTool->flags() & Qgis::PlotToolFlag::ShowContextMenu ) { - std::unique_ptr me( new QgsPlotMouseEvent( this, event ) ); + auto me = std::make_unique( this, event ); showContextMenu( me.get() ); event->accept(); return; @@ -184,7 +184,7 @@ void QgsPlotCanvas::mouseReleaseEvent( QMouseEvent *event ) { if ( mTool ) { - std::unique_ptr me( new QgsPlotMouseEvent( this, event ) ); + auto me = std::make_unique( this, event ); mTool->plotReleaseEvent( me.get() ); event->setAccepted( me->isAccepted() ); } @@ -216,7 +216,7 @@ void QgsPlotCanvas::mouseMoveEvent( QMouseEvent *event ) { if ( mTool ) { - std::unique_ptr me( new QgsPlotMouseEvent( this, event ) ); + auto me = std::make_unique( this, event ); mTool->plotMoveEvent( me.get() ); event->setAccepted( me->isAccepted() ); } diff --git a/src/gui/processing/models/qgsmodelgraphicsview.cpp b/src/gui/processing/models/qgsmodelgraphicsview.cpp index 84c697d6bfc..f9dd4f7c1dc 100644 --- a/src/gui/processing/models/qgsmodelgraphicsview.cpp +++ b/src/gui/processing/models/qgsmodelgraphicsview.cpp @@ -222,7 +222,7 @@ void QgsModelGraphicsView::mousePressEvent( QMouseEvent *event ) if ( mTool ) { - std::unique_ptr me( new QgsModelViewMouseEvent( this, event, mTool->flags() & QgsModelViewTool::FlagSnaps ) ); + auto me = std::make_unique( this, event, mTool->flags() & QgsModelViewTool::FlagSnaps ); mTool->modelPressEvent( me.get() ); event->setAccepted( me->isAccepted() ); } @@ -249,7 +249,7 @@ void QgsModelGraphicsView::mouseReleaseEvent( QMouseEvent *event ) if ( mTool ) { - std::unique_ptr me( new QgsModelViewMouseEvent( this, event, mTool->flags() & QgsModelViewTool::FlagSnaps ) ); + auto me = std::make_unique( this, event, mTool->flags() & QgsModelViewTool::FlagSnaps ); mTool->modelReleaseEvent( me.get() ); event->setAccepted( me->isAccepted() ); } @@ -268,7 +268,7 @@ void QgsModelGraphicsView::mouseMoveEvent( QMouseEvent *event ) QPointF cursorPos = mapToScene( mMouseCurrentXY ); if ( mTool ) { - std::unique_ptr me( new QgsModelViewMouseEvent( this, event, false ) ); + auto me = std::make_unique( this, event, false ); if ( mTool->flags() & QgsModelViewTool::FlagSnaps ) { me->snapPoint(); @@ -305,7 +305,7 @@ void QgsModelGraphicsView::mouseDoubleClickEvent( QMouseEvent *event ) if ( mTool ) { - std::unique_ptr me( new QgsModelViewMouseEvent( this, event, mTool->flags() & QgsModelViewTool::FlagSnaps ) ); + auto me = std::make_unique( this, event, mTool->flags() & QgsModelViewTool::FlagSnaps ); mTool->modelDoubleClickEvent( me.get() ); event->setAccepted( me->isAccepted() ); } diff --git a/src/gui/providers/ogr/qgsgeopackageitemguiprovider.cpp b/src/gui/providers/ogr/qgsgeopackageitemguiprovider.cpp index 3a3874100a4..5f7ee27fbf8 100644 --- a/src/gui/providers/ogr/qgsgeopackageitemguiprovider.cpp +++ b/src/gui/providers/ogr/qgsgeopackageitemguiprovider.cpp @@ -435,7 +435,7 @@ bool QgsGeoPackageItemGuiProvider::handleDropGeopackage( QgsGeoPackageCollection bool hasError = false; // Main task - std::unique_ptr mainTask( new QgsTaskWithSerialSubTasks( tr( "GeoPackage import" ) ) ); + auto mainTask = std::make_unique( tr( "GeoPackage import" ) ); bool hasSubTasks = false; const auto lst = QgsMimeDataUtils::decodeUriList( data ); diff --git a/src/gui/providers/ogr/qgsogrdbsourceselect.cpp b/src/gui/providers/ogr/qgsogrdbsourceselect.cpp index e04ddfa353c..c6681f88008 100644 --- a/src/gui/providers/ogr/qgsogrdbsourceselect.cpp +++ b/src/gui/providers/ogr/qgsogrdbsourceselect.cpp @@ -321,7 +321,7 @@ void QgsOgrDbSourceSelect::setSql( const QModelIndex &index ) } // create a query builder object - std::unique_ptr gb( new QgsQueryBuilder( vlayer.get(), this ) ); + auto gb = std::make_unique( vlayer.get(), this ); if ( gb->exec() ) { diff --git a/src/gui/qgsformannotation.cpp b/src/gui/qgsformannotation.cpp index e5a8a1680ff..fa67b970e3e 100644 --- a/src/gui/qgsformannotation.cpp +++ b/src/gui/qgsformannotation.cpp @@ -46,7 +46,7 @@ QgsFormAnnotation::QgsFormAnnotation( QObject *parent ) QgsFormAnnotation *QgsFormAnnotation::clone() const { - std::unique_ptr c( new QgsFormAnnotation() ); + auto c = std::make_unique(); copyCommonProperties( c.get() ); c->setDesignerForm( mDesignerForm ); return c.release(); diff --git a/src/gui/qgsguiutils.cpp b/src/gui/qgsguiutils.cpp index 28a921a0ad3..cc9c89ba387 100644 --- a/src/gui/qgsguiutils.cpp +++ b/src/gui/qgsguiutils.cpp @@ -147,7 +147,7 @@ namespace QgsGuiUtils outputFileName = QFileDialog::getSaveFileName( parent, message, initialPath, formatByExtension + QStringLiteral( ";;" ) + qgsMapJoinKeys( filterMap, QStringLiteral( ";;" ) ), &selectedFilter ); #else //create a file dialog using the filter list generated above - std::unique_ptr fileDialog( new QFileDialog( parent, message, initialPath, formatByExtension + QStringLiteral( ";;" ) + qgsMapJoinKeys( filterMap, QStringLiteral( ";;" ) ) ) ); + auto fileDialog = std::make_unique( parent, message, initialPath, formatByExtension + QStringLiteral( ";;" ) + qgsMapJoinKeys( filterMap, QStringLiteral( ";;" ) ) ); // allow for selection of more than one file fileDialog->setFileMode( QFileDialog::AnyFile ); diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index c0ceac34e9c..f08c20df9f9 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -2419,7 +2419,7 @@ void QgsMapCanvas::mouseDoubleClickEvent( QMouseEvent *e ) // call handler of current map tool if ( mMapTool ) { - std::unique_ptr me( new QgsMapMouseEvent( this, e ) ); + auto me = std::make_unique( this, e ); mMapTool->canvasDoubleClickEvent( me.get() ); } } // mouseDoubleClickEvent @@ -2528,13 +2528,13 @@ void QgsMapCanvas::mousePressEvent( QMouseEvent *e ) } else if ( mMapTool->flags() & QgsMapTool::ShowContextMenu && e->button() == Qt::RightButton ) { - std::unique_ptr me( new QgsMapMouseEvent( this, e ) ); + auto me = std::make_unique( this, e ); showContextMenu( me.get() ); return; } else { - std::unique_ptr me( new QgsMapMouseEvent( this, e ) ); + auto me = std::make_unique( this, e ); mMapTool->canvasPressEvent( me.get() ); } } @@ -2583,7 +2583,7 @@ void QgsMapCanvas::mouseReleaseEvent( QMouseEvent *e ) // call handler of current map tool if ( mMapTool ) { - std::unique_ptr me( new QgsMapMouseEvent( this, e ) ); + auto me = std::make_unique( this, e ); mMapTool->canvasReleaseEvent( me.get() ); } } @@ -2762,7 +2762,7 @@ void QgsMapCanvas::mouseMoveEvent( QMouseEvent *e ) // call handler of current map tool if ( mMapTool ) { - std::unique_ptr me( new QgsMapMouseEvent( this, e ) ); + auto me = std::make_unique( this, e ); mMapTool->canvasMoveEvent( me.get() ); } } diff --git a/src/gui/raster/qgsrasterlayerproperties.cpp b/src/gui/raster/qgsrasterlayerproperties.cpp index 0c7496dcae7..5179b633671 100644 --- a/src/gui/raster/qgsrasterlayerproperties.cpp +++ b/src/gui/raster/qgsrasterlayerproperties.cpp @@ -1094,7 +1094,7 @@ void QgsRasterLayerProperties::buttonBuildPyramids_clicked() { QgsRasterDataProvider *provider = mRasterLayer->dataProvider(); - std::unique_ptr feedback( new QgsRasterBlockFeedback() ); + auto feedback = std::make_unique(); connect( feedback.get(), &QgsRasterBlockFeedback::progressChanged, mPyramidProgress, &QProgressBar::setValue ); // diff --git a/src/providers/oracle/qgsoracleprovider.cpp b/src/providers/oracle/qgsoracleprovider.cpp index 80091bc7016..3e070a29c93 100644 --- a/src/providers/oracle/qgsoracleprovider.cpp +++ b/src/providers/oracle/qgsoracleprovider.cpp @@ -3255,7 +3255,7 @@ Qgis::VectorExportResult QgsOracleProvider::createEmptyLayer( const QString &uri dsUri.setWkbType( wkbType ); QgsDataProvider::ProviderOptions providerOptions; - std::unique_ptr provider( new QgsOracleProvider( dsUri.uri( false ), providerOptions ) ); + auto provider = std::make_unique( dsUri.uri( false ), providerOptions ); if ( !provider->isValid() ) { errorMessage = QObject::tr( "Loading of the layer %1 failed" ).arg( ownerTableName ); diff --git a/src/providers/postgres/qgspostgresdataitems.cpp b/src/providers/postgres/qgspostgresdataitems.cpp index 1d7138f371d..c02eb4706e9 100644 --- a/src/providers/postgres/qgspostgresdataitems.cpp +++ b/src/providers/postgres/qgspostgresdataitems.cpp @@ -149,7 +149,7 @@ bool QgsPGConnectionItem::handleDrop( const QMimeData *data, const QString &toSc uri.setSchema( toSchema ); } - std::unique_ptr exportTask( new QgsVectorLayerExporterTask( srcLayer, uri.uri( false ), QStringLiteral( "postgres" ), srcLayer->crs(), QVariantMap(), owner ) ); + auto exportTask = std::make_unique( srcLayer, uri.uri( false ), QStringLiteral( "postgres" ), srcLayer->crs(), QVariantMap(), owner ); // when export is successful: connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, this, [=]() { diff --git a/src/providers/postgres/qgspostgreslistener.cpp b/src/providers/postgres/qgspostgreslistener.cpp index c56644def41..c4a371bec71 100644 --- a/src/providers/postgres/qgspostgreslistener.cpp +++ b/src/providers/postgres/qgspostgreslistener.cpp @@ -35,7 +35,7 @@ extern "C" std::unique_ptr QgsPostgresListener::create( const QString &connString ) { - std::unique_ptr res( new QgsPostgresListener( connString ) ); + auto res = std::make_unique( connString ); QgsDebugMsgLevel( QStringLiteral( "starting notification listener" ), 2 ); res->start(); diff --git a/src/providers/postgres/qgspostgreslistener.h b/src/providers/postgres/qgspostgreslistener.h index 13084156c77..74a734e3f63 100644 --- a/src/providers/postgres/qgspostgreslistener.h +++ b/src/providers/postgres/qgspostgreslistener.h @@ -44,6 +44,7 @@ class QgsPostgresListener : public QThread */ static std::unique_ptr create( const QString &connString ); + QgsPostgresListener( const QString &connString ); ~QgsPostgresListener() override; void run() override; @@ -56,8 +57,6 @@ class QgsPostgresListener : public QThread QgsPostgresConn *mConn = nullptr; - QgsPostgresListener( const QString &connString ); - Q_DISABLE_COPY( QgsPostgresListener ) }; diff --git a/src/providers/spatialite/qgsspatialitedataitemguiprovider.cpp b/src/providers/spatialite/qgsspatialitedataitemguiprovider.cpp index 7251ab7648b..1031e8e2724 100644 --- a/src/providers/spatialite/qgsspatialitedataitemguiprovider.cpp +++ b/src/providers/spatialite/qgsspatialitedataitemguiprovider.cpp @@ -173,7 +173,7 @@ bool QgsSpatiaLiteDataItemGuiProvider::handleDropConnectionItem( QgsSLConnection destUri.setDataSource( QString(), u.name, srcLayer->geometryType() != Qgis::GeometryType::Null ? QStringLiteral( "geom" ) : QString() ); QgsDebugMsgLevel( "URI " + destUri.uri(), 2 ); - std::unique_ptr exportTask( new QgsVectorLayerExporterTask( srcLayer, destUri.uri(), QStringLiteral( "spatialite" ), srcLayer->crs(), QVariantMap(), owner ) ); + auto exportTask = std::make_unique( srcLayer, destUri.uri(), QStringLiteral( "spatialite" ), srcLayer->crs(), QVariantMap(), owner ); // when export is successful: connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, connItem, [=]() { diff --git a/src/providers/virtual/qgsvirtuallayersourceselect.cpp b/src/providers/virtual/qgsvirtuallayersourceselect.cpp index de176916a15..bd0385debd1 100644 --- a/src/providers/virtual/qgsvirtuallayersourceselect.cpp +++ b/src/providers/virtual/qgsvirtuallayersourceselect.cpp @@ -257,7 +257,7 @@ bool QgsVirtualLayerSourceSelect::preFlight() if ( !def.toString().isEmpty() ) { const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; - std::unique_ptr vl( new QgsVectorLayer( def.toString(), QStringLiteral( "test" ), QStringLiteral( "virtual" ), options ) ); + auto vl = std::make_unique( def.toString(), QStringLiteral( "test" ), QStringLiteral( "virtual" ), options ); if ( vl->isValid() ) { const QStringList fieldNames = vl->fields().names(); diff --git a/src/providers/virtualraster/qgsvirtualrasterprovider.cpp b/src/providers/virtualraster/qgsvirtualrasterprovider.cpp index 499947f1a94..425096171a1 100644 --- a/src/providers/virtualraster/qgsvirtualrasterprovider.cpp +++ b/src/providers/virtualraster/qgsvirtualrasterprovider.cpp @@ -165,7 +165,7 @@ QgsRasterBlock *QgsVirtualRasterProvider::block( int bandNo, const QgsRectangle proj.setInput( it->raster->dataProvider() ); proj.setPrecision( QgsRasterProjector::Exact ); - std::unique_ptr rasterBlockFeedback( new QgsRasterBlockFeedback() ); + auto rasterBlockFeedback = std::make_unique(); QObject::connect( feedback, &QgsFeedback::canceled, rasterBlockFeedback.get(), &QgsRasterBlockFeedback::cancel ); block.reset( proj.block( it->bandNumber, extent, width, height, rasterBlockFeedback.get() ) ); if ( rasterBlockFeedback->isCanceled() ) diff --git a/src/server/qgsconfigcache.cpp b/src/server/qgsconfigcache.cpp index 3bf9412f339..1947c06600b 100644 --- a/src/server/qgsconfigcache.cpp +++ b/src/server/qgsconfigcache.cpp @@ -103,7 +103,7 @@ const QgsProject *QgsConfigCache::project( const QString &path, const QgsServerS if ( !mProjectCache[path] ) { // disable the project style database -- this incurs unwanted cost and is not required - std::unique_ptr prj( new QgsProject( nullptr, Qgis::ProjectCapabilities() ) ); + auto prj = std::make_unique( nullptr, Qgis::ProjectCapabilities() ); // This is required by virtual layers that call QgsProject::instance() inside the constructor :( QgsProject::setInstance( prj.get() ); diff --git a/src/server/services/wfs/qgswfsgetfeature.cpp b/src/server/services/wfs/qgswfsgetfeature.cpp index eea736de0f2..3ca638178e1 100644 --- a/src/server/services/wfs/qgswfsgetfeature.cpp +++ b/src/server/services/wfs/qgswfsgetfeature.cpp @@ -196,7 +196,7 @@ namespace QgsWfs QgsAccessControl *accessControl = serverIface->accessControls(); //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - std::unique_ptr filterRestorer( new QgsOWSServerFilterRestorer() ); + auto filterRestorer = std::make_unique(); #else ( void ) serverIface; #endif diff --git a/src/server/services/wfs/qgswfstransaction.cpp b/src/server/services/wfs/qgswfstransaction.cpp index bf27820bb74..92ef2769274 100644 --- a/src/server/services/wfs/qgswfstransaction.cpp +++ b/src/server/services/wfs/qgswfstransaction.cpp @@ -249,7 +249,7 @@ namespace QgsWfs //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - std::unique_ptr filterRestorer( new QgsOWSServerFilterRestorer() ); + auto filterRestorer = std::make_unique(); // get layers QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *project ); diff --git a/src/server/services/wfs/qgswfstransaction_1_0_0.cpp b/src/server/services/wfs/qgswfstransaction_1_0_0.cpp index e753d117db3..411adcaefcd 100644 --- a/src/server/services/wfs/qgswfstransaction_1_0_0.cpp +++ b/src/server/services/wfs/qgswfstransaction_1_0_0.cpp @@ -233,7 +233,7 @@ namespace QgsWfs //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - std::unique_ptr filterRestorer( new QgsOWSServerFilterRestorer() ); + auto filterRestorer = std::make_unique(); // get layers QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *project ); diff --git a/src/server/services/wfs3/qgswfs3handlers.cpp b/src/server/services/wfs3/qgswfs3handlers.cpp index 99ae8749e45..d7b4ee6290e 100644 --- a/src/server/services/wfs3/qgswfs3handlers.cpp +++ b/src/server/services/wfs3/qgswfs3handlers.cpp @@ -1241,7 +1241,7 @@ void QgsWfs3CollectionsItemsHandler::handleRequest( const QgsServerApiContext &c //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - std::unique_ptr filterRestorer( new QgsOWSServerFilterRestorer() ); + auto filterRestorer = std::make_unique(); if ( accessControl ) { QgsOWSServerFilterRestorer::applyAccessControlLayerFilters( accessControl, mapLayer, filterRestorer->originalFilters() ); @@ -1434,7 +1434,7 @@ void QgsWfs3CollectionsFeatureHandler::handleRequest( const QgsServerApiContext QgsAccessControl *accessControl = context.serverInterface()->accessControls(); //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - std::unique_ptr filterRestorer( new QgsOWSServerFilterRestorer() ); + auto filterRestorer = std::make_unique(); if ( accessControl ) { QgsOWSServerFilterRestorer::applyAccessControlLayerFilters( accessControl, mapLayer, filterRestorer->originalFilters() ); @@ -1498,7 +1498,7 @@ void QgsWfs3CollectionsFeatureHandler::handleRequest( const QgsServerApiContext //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - std::unique_ptr filterRestorer( new QgsOWSServerFilterRestorer() ); + auto filterRestorer = std::make_unique(); if ( accessControl ) { QgsOWSServerFilterRestorer::applyAccessControlLayerFilters( accessControl, mapLayer, filterRestorer->originalFilters() ); @@ -1629,7 +1629,7 @@ void QgsWfs3CollectionsFeatureHandler::handleRequest( const QgsServerApiContext //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - std::unique_ptr filterRestorer( new QgsOWSServerFilterRestorer() ); + auto filterRestorer = std::make_unique(); if ( accessControl ) { QgsOWSServerFilterRestorer::applyAccessControlLayerFilters( accessControl, mapLayer, filterRestorer->originalFilters() ); @@ -1748,7 +1748,7 @@ void QgsWfs3CollectionsFeatureHandler::handleRequest( const QgsServerApiContext //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - std::unique_ptr filterRestorer( new QgsOWSServerFilterRestorer() ); + auto filterRestorer = std::make_unique(); if ( accessControl ) { QgsOWSServerFilterRestorer::applyAccessControlLayerFilters( accessControl, mapLayer, filterRestorer->originalFilters() ); diff --git a/src/server/services/wms/qgswmsgetlegendgraphics.cpp b/src/server/services/wms/qgswmsgetlegendgraphics.cpp index 1cf98c8939a..48e3bb552be 100644 --- a/src/server/services/wms/qgswmsgetlegendgraphics.cpp +++ b/src/server/services/wms/qgswmsgetlegendgraphics.cpp @@ -243,7 +243,7 @@ namespace QgsWms QgsLayerTreeModel *legendModel( const QgsWmsRenderContext &context, QgsLayerTree &tree ) { const QgsWmsParameters parameters = context.parameters(); - std::unique_ptr model( new QgsLayerTreeModel( &tree ) ); + auto model = std::make_unique( &tree ); std::unique_ptr mapSettings; if ( context.scaleDenominator() > 0 ) @@ -320,7 +320,7 @@ namespace QgsWms QgsLayerTree *layerTree( const QgsWmsRenderContext &context ) { - std::unique_ptr tree( new QgsLayerTree() ); + auto tree = std::make_unique(); QList counters; for ( QgsMapLayer *ml : context.layersToRender() ) @@ -363,7 +363,7 @@ namespace QgsWms return 0; } - std::unique_ptr tree( new QgsLayerTree() ); + auto tree = std::make_unique(); QgsWmsParameters wmsParams = context.parameters(); QStringList layerNicknames = wmsParams.allLayersNickname(); diff --git a/src/server/services/wms/qgswmsrenderer.cpp b/src/server/services/wms/qgswmsrenderer.cpp index 4001387f424..51e637df80d 100644 --- a/src/server/services/wms/qgswmsrenderer.cpp +++ b/src/server/services/wms/qgswmsrenderer.cpp @@ -528,7 +528,7 @@ namespace QgsWms configureLayers( layers, &mapSettings ); // configure map settings (background, DPI, ...) - std::unique_ptr image( new QImage() ); + auto image = std::make_unique(); configureMapSettings( image.get(), mapSettings ); // add layers to map settings @@ -3606,7 +3606,7 @@ namespace QgsWms } if ( !exp.isEmpty() ) { - std::unique_ptr expression( new QgsExpression( exp ) ); + auto expression = std::make_unique( exp ); if ( expression ) { mFeatureFilter.setFilter( filteredLayer, *expression ); diff --git a/tests/src/3d/testqgs3drendering.cpp b/tests/src/3d/testqgs3drendering.cpp index 8a34801bad7..02f28cb7a76 100644 --- a/tests/src/3d/testqgs3drendering.cpp +++ b/tests/src/3d/testqgs3drendering.cpp @@ -207,9 +207,9 @@ void TestQgs3DRendering::initTestCase() QColor cMin = Qt::red, cMax = Qt::yellow; // change renderer for the new style - std::unique_ptr colorRampShader( new QgsColorRampShader( vMin, vMax ) ); + auto colorRampShader = std::make_unique( vMin, vMax ); colorRampShader->setColorRampItemList( QList() << QgsColorRampShader::ColorRampItem( vMin, cMin ) << QgsColorRampShader::ColorRampItem( vMax, cMax ) ); - std::unique_ptr shader( new QgsRasterShader( vMin, vMax ) ); + auto shader = std::make_unique( vMin, vMax ); shader->setRasterShaderFunction( colorRampShader.release() ); QgsSingleBandPseudoColorRenderer *r = new QgsSingleBandPseudoColorRenderer( mLayerDtm->renderer()->input(), 1, shader.release() ); mLayerDtm->setRenderer( r ); @@ -1545,7 +1545,7 @@ void TestQgs3DRendering::testInstancedRendering() { const QgsRectangle fullExtent( 1000, 1000, 2000, 2000 ); - std::unique_ptr layerPointsZ( new QgsVectorLayer( "PointZ?crs=EPSG:27700", "points Z", "memory" ) ); + auto layerPointsZ = std::make_unique( "PointZ?crs=EPSG:27700", "points Z", "memory" ); QgsPoint *p1 = new QgsPoint( 1000, 1000, 50 ); QgsPoint *p2 = new QgsPoint( 1000, 2000, 100 ); @@ -1620,7 +1620,7 @@ void TestQgs3DRendering::testInstancedRenderingClipping() { const QgsRectangle fullExtent( 1000, 1000, 2000, 2000 ); - std::unique_ptr layerPointsZ( new QgsVectorLayer( "PointZ?crs=EPSG:27700", "points Z", "memory" ) ); + auto layerPointsZ = std::make_unique( "PointZ?crs=EPSG:27700", "points Z", "memory" ); QgsPoint *p1 = new QgsPoint( 1000, 1000, 50 ); QgsPoint *p2 = new QgsPoint( 1000, 2000, 100 ); @@ -1720,7 +1720,7 @@ void TestQgs3DRendering::testBillboardRendering() { const QgsRectangle fullExtent( 1000, 1000, 2000, 2000 ); - std::unique_ptr layerPointsZ( new QgsVectorLayer( "PointZ?crs=EPSG:27700", "points Z", "memory" ) ); + auto layerPointsZ = std::make_unique( "PointZ?crs=EPSG:27700", "points Z", "memory" ); QgsPoint *p1 = new QgsPoint( 1000, 1000, 50 ); QgsPoint *p2 = new QgsPoint( 1000, 2000, 100 ); diff --git a/tests/src/analysis/testqgsprocessing.cpp b/tests/src/analysis/testqgsprocessing.cpp index ea2041dedda..8e5655132b7 100644 --- a/tests/src/analysis/testqgsprocessing.cpp +++ b/tests/src/analysis/testqgsprocessing.cpp @@ -2141,7 +2141,7 @@ void TestQgsProcessing::generateTemporaryDestination() context.setProject( &p ); // destination vector with "." in it's name - std::unique_ptr def( new QgsProcessingParameterVectorDestination( "with.inside", QString(), Qgis::ProcessingSourceType::VectorAnyGeometry, QString(), false ) ); + auto def = std::make_unique( "with.inside", QString(), Qgis::ProcessingSourceType::VectorAnyGeometry, QString(), false ); // check that temporary destination does not have dot at the end when there is no extension QVERIFY( !def->generateTemporaryDestination().endsWith( QLatin1Char( '.' ) ) ); @@ -2152,7 +2152,7 @@ void TestQgsProcessing::generateTemporaryDestination() QCOMPARE( f.completeSuffix(), QString( "gpkg" ) ); // destination raster with "." in it's name - std::unique_ptr def2( new QgsProcessingParameterRasterDestination( "with.inside", QString(), QString(), false ) ); + auto def2 = std::make_unique( "with.inside", QString(), QString(), false ); // check that temporary destination does not have dot at the end when there is no extension QVERIFY( !def2->generateTemporaryDestination().endsWith( QLatin1Char( '.' ) ) ); @@ -2163,7 +2163,7 @@ void TestQgsProcessing::generateTemporaryDestination() QCOMPARE( f.completeSuffix(), QString( "tif" ) ); // destination vector without "." in it's name - std::unique_ptr def3( new QgsProcessingParameterVectorDestination( "without_inside", QString(), Qgis::ProcessingSourceType::VectorAnyGeometry, QString(), false ) ); + auto def3 = std::make_unique( "without_inside", QString(), Qgis::ProcessingSourceType::VectorAnyGeometry, QString(), false ); // check that temporary destination does not have dot at the end when there is no extension QVERIFY( !def3->generateTemporaryDestination().endsWith( QLatin1Char( '.' ) ) ); @@ -3186,7 +3186,7 @@ void TestQgsProcessing::parameterCrs() context.setProject( &p ); // not optional, with default value - std::unique_ptr def( new QgsProcessingParameterCrs( "non_optional", QString(), QString( "EPSG:3113" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString( "EPSG:3113" ), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -3376,7 +3376,7 @@ void TestQgsProcessing::parameterMapLayer() context.setProject( &p ); // not optional, no default value - std::unique_ptr def( new QgsProcessingParameterMapLayer( "non_optional", QString(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -3591,7 +3591,7 @@ void TestQgsProcessing::parameterExtent() context.setProject( &p ); // not optional, with default value - std::unique_ptr def( new QgsProcessingParameterExtent( "non_optional", QString(), QString( "1,2,3,4" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString( "1,2,3,4" ), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -3962,7 +3962,7 @@ void TestQgsProcessing::parameterPoint() QgsProcessingContext context; // not optional, with default value - std::unique_ptr def( new QgsProcessingParameterPoint( "non_optional", QString(), QString( "1,2" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString( "1,2" ), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -4199,7 +4199,7 @@ void TestQgsProcessing::parameterGeometry() QgsProcessingContext context; // not optional, default value - std::unique_ptr def( new QgsProcessingParameterGeometry( "non_optional", QString(), QString( "Point(1 2)" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString( "Point(1 2)" ), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -4447,7 +4447,7 @@ void TestQgsProcessing::parameterFile() QgsProcessingContext context; // not optional, with default value - std::unique_ptr def( new QgsProcessingParameterFile( "non_optional", QString(), Qgis::ProcessingFileParameterBehavior::File, QString(), QString( "abc.bmp" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), Qgis::ProcessingFileParameterBehavior::File, QString(), QString( "abc.bmp" ), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -4673,7 +4673,7 @@ void TestQgsProcessing::parameterMatrix() QgsProcessingContext context; // not optional, no default value - std::unique_ptr def( new QgsProcessingParameterMatrix( "non_optional", QString(), 3, false, QStringList(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), 3, false, QStringList(), QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( def->checkValueIsAcceptable( 5 ) ); @@ -4837,7 +4837,7 @@ void TestQgsProcessing::parameterLayerList() context.setProject( &p ); // not optional, no default value - std::unique_ptr def( new QgsProcessingParameterMultipleLayers( "non_optional", QString(), Qgis::ProcessingSourceType::MapLayer, QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), Qgis::ProcessingSourceType::MapLayer, QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -5190,7 +5190,7 @@ void TestQgsProcessing::parameterDistance() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterDistance( "non_optional", QString(), 5, QStringLiteral( "parent" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), 5, QStringLiteral( "parent" ), false ); QCOMPARE( def->parentParameterName(), QStringLiteral( "parent" ) ); def->setParentParameterName( QStringLiteral( "parent2" ) ); QCOMPARE( def->defaultUnit(), Qgis::DistanceUnit::Unknown ); @@ -5306,7 +5306,7 @@ void TestQgsProcessing::parameterArea() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterArea( "non_optional", QString(), 5, QStringLiteral( "parent" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), 5, QStringLiteral( "parent" ), false ); QCOMPARE( def->parentParameterName(), QStringLiteral( "parent" ) ); def->setParentParameterName( QStringLiteral( "parent2" ) ); QCOMPARE( def->defaultUnit(), Qgis::AreaUnit::Unknown ); @@ -5422,7 +5422,7 @@ void TestQgsProcessing::parameterVolume() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterVolume( "non_optional", QString(), 5, QStringLiteral( "parent" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), 5, QStringLiteral( "parent" ), false ); QCOMPARE( def->parentParameterName(), QStringLiteral( "parent" ) ); def->setParentParameterName( QStringLiteral( "parent2" ) ); QCOMPARE( def->defaultUnit(), Qgis::VolumeUnit::Unknown ); @@ -5538,7 +5538,7 @@ void TestQgsProcessing::parameterDuration() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterDuration( "non_optional", QString(), 5, false ) ); + auto def = std::make_unique( "non_optional", QString(), 5, false ); QCOMPARE( def->defaultUnit(), Qgis::TemporalUnit::Milliseconds ); def->setDefaultUnit( Qgis::TemporalUnit::Days ); QCOMPARE( def->defaultUnit(), Qgis::TemporalUnit::Days ); @@ -5646,7 +5646,7 @@ void TestQgsProcessing::parameterScale() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterScale( "non_optional", QString(), 5, false ) ); + auto def = std::make_unique( "non_optional", QString(), 5, false ); QVERIFY( def->checkValueIsAcceptable( 5 ) ); QVERIFY( def->checkValueIsAcceptable( "1.1" ) ); @@ -5757,7 +5757,7 @@ void TestQgsProcessing::parameterNumber() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterNumber( "non_optional", QString(), Qgis::ProcessingNumberParameterType::Double, 5, false ) ); + auto def = std::make_unique( "non_optional", QString(), Qgis::ProcessingNumberParameterType::Double, 5, false ); QVERIFY( def->checkValueIsAcceptable( 5 ) ); QVERIFY( def->checkValueIsAcceptable( "1.1" ) ); QVERIFY( !def->checkValueIsAcceptable( "1.1,2" ) ); @@ -5903,7 +5903,7 @@ void TestQgsProcessing::parameterRange() QgsProcessingContext context; // not optional, with default value - std::unique_ptr def( new QgsProcessingParameterRange( "non_optional", QString(), Qgis::ProcessingNumberParameterType::Double, QString( "5,6" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), Qgis::ProcessingNumberParameterType::Double, QString( "5,6" ), false ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); QVERIFY( !def->checkValueIsAcceptable( "1.1" ) ); QVERIFY( def->checkValueIsAcceptable( "1.1,2" ) ); @@ -6089,7 +6089,7 @@ void TestQgsProcessing::parameterRasterLayer() context.setProject( &p ); // not optional, no default value - std::unique_ptr def( new QgsProcessingParameterRasterLayer( "non_optional", QString(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -6242,7 +6242,7 @@ void TestQgsProcessing::parameterEnum() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterEnum( "non_optional", QString(), QStringList() << "A" << "B" << "C", false, 2, false ) ); + auto def = std::make_unique( "non_optional", QString(), QStringList() << "A" << "B" << "C", false, 2, false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); @@ -6617,7 +6617,7 @@ void TestQgsProcessing::parameterString() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterString( "non_optional", QString(), QString(), false, false ) ); + auto def = std::make_unique( "non_optional", QString(), QString(), false, false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -6797,7 +6797,7 @@ void TestQgsProcessing::parameterAuthConfig() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterAuthConfig( "non_optional", QString(), QString(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString(), false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -6934,7 +6934,7 @@ void TestQgsProcessing::parameterExpression() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterExpression( "non_optional", QString(), QString( "1+1" ), QString(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString( "1+1" ), QString(), false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -7044,7 +7044,7 @@ void TestQgsProcessing::parameterField() QgsProcessingContext context; // not optional, no default value - std::unique_ptr def( new QgsProcessingParameterField( "non_optional", QString(), QVariant(), QString(), Qgis::ProcessingFieldParameterDataType::Any, false, false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), QString(), Qgis::ProcessingFieldParameterDataType::Any, false, false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( QStringList() << "a" << "b" ) ); @@ -7352,7 +7352,7 @@ void TestQgsProcessing::parameterVectorLayer() context.setProject( &p ); // not optional, with default value - std::unique_ptr def( new QgsProcessingParameterVectorLayer( "non_optional", QString(), QList(), QString( "somelayer" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), QList(), QString( "somelayer" ), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -7514,7 +7514,7 @@ void TestQgsProcessing::parameterMeshLayer() context.setProject( &p ); // not optional, with default value - std::unique_ptr def( new QgsProcessingParameterMeshLayer( "non_optional", QString(), QString( "somelayer" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString( "somelayer" ), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -7674,7 +7674,7 @@ void TestQgsProcessing::parameterFeatureSource() context.setProject( &p ); // not optional! - std::unique_ptr def( new QgsProcessingParameterFeatureSource( "non_optional", QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ), QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -7929,7 +7929,7 @@ void TestQgsProcessing::parameterFeatureSink() context.setProject( &p ); // not optional, no default value - std::unique_ptr def( new QgsProcessingParameterFeatureSink( "non_optional", QString(), Qgis::ProcessingSourceType::VectorAnyGeometry, QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), Qgis::ProcessingSourceType::VectorAnyGeometry, QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -8135,7 +8135,7 @@ void TestQgsProcessing::parameterVectorOut() context.setProject( &p ); // not optional, no default - std::unique_ptr def( new QgsProcessingParameterVectorDestination( "non_optional", QString(), Qgis::ProcessingSourceType::VectorAnyGeometry, QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), Qgis::ProcessingSourceType::VectorAnyGeometry, QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -8373,7 +8373,7 @@ void TestQgsProcessing::parameterRasterOut() context.setProject( &p ); // not optional, no default - std::unique_ptr def( new QgsProcessingParameterRasterDestination( "non_optional", QString(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -8540,7 +8540,7 @@ void TestQgsProcessing::parameterPointCloudOut() context.setProject( &p ); // not optional, no default - std::unique_ptr def( new QgsProcessingParameterPointCloudDestination( "non_optional", QString(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -8709,7 +8709,7 @@ void TestQgsProcessing::parameterFileOut() context.setProject( &p ); // not optional! - std::unique_ptr def( new QgsProcessingParameterFileDestination( "non_optional", QString(), QStringLiteral( "BMP files (*.bmp)" ), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QStringLiteral( "BMP files (*.bmp)" ), QVariant(), false ); QCOMPARE( def->fileFilter(), QStringLiteral( "BMP files (*.bmp)" ) ); QCOMPARE( def->defaultFileExtension(), QStringLiteral( "bmp" ) ); QVERIFY( def->generateTemporaryDestination().endsWith( QLatin1String( ".bmp" ) ) ); @@ -8874,7 +8874,7 @@ void TestQgsProcessing::parameterFolderOut() context.setProject( &p ); // not optional! - std::unique_ptr def( new QgsProcessingParameterFolderDestination( "non_optional", QString(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); @@ -8990,7 +8990,7 @@ void TestQgsProcessing::parameterVectorTileOut() context.setProject( &p ); // not optional, no default - std::unique_ptr def( new QgsProcessingParameterVectorTileDestination( "non_optional", QString(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -9155,7 +9155,7 @@ void TestQgsProcessing::parameterBand() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterBand( "non_optional", QString(), QVariant(), QString(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), QString(), false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "1" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -9315,7 +9315,7 @@ void TestQgsProcessing::parameterLayout() p.layoutManager()->addLayout( l2 ); // not optional! - std::unique_ptr def( new QgsProcessingParameterLayout( "non_optional", QString(), QString(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString(), false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -9474,7 +9474,7 @@ void TestQgsProcessing::parameterLayoutItem() QgsPrintLayout *l2 = new QgsPrintLayout( &p ); // not optional! - std::unique_ptr def( new QgsProcessingParameterLayoutItem( "non_optional", QString(), QVariant(), QString(), -1, false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), QString(), -1, false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -9621,7 +9621,7 @@ void TestQgsProcessing::parameterColor() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterColor( "non_optional", QString(), QVariant(), true, false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), true, false ); QVERIFY( def->opacityEnabled() ); def->setOpacityEnabled( false ); QVERIFY( !def->opacityEnabled() ); @@ -9798,7 +9798,7 @@ void TestQgsProcessing::parameterCoordinateOperation() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterCoordinateOperation( "non_optional", QString(), QString(), QString(), QString(), QVariant(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString(), QString(), QString(), QVariant(), QVariant(), false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -9949,7 +9949,7 @@ void TestQgsProcessing::parameterMapTheme() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterMapTheme( "non_optional", QString(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -10093,7 +10093,7 @@ void TestQgsProcessing::parameterProviderConnection() QgsProcessingContext context; // not optional, no default - std::unique_ptr def( new QgsProcessingParameterProviderConnection( "non_optional", QString(), QStringLiteral( "ogr" ), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QStringLiteral( "ogr" ), QVariant(), false ); QCOMPARE( def->providerId(), QStringLiteral( "ogr" ) ); def->setProviderId( QStringLiteral( "postgres" ) ); QCOMPARE( def->providerId(), QStringLiteral( "postgres" ) ); @@ -10251,7 +10251,7 @@ void TestQgsProcessing::parameterDatabaseSchema() QgsProcessingContext context; // not optional, no default - std::unique_ptr def( new QgsProcessingParameterDatabaseSchema( "non_optional", QString(), QString(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString(), QVariant(), false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -10349,7 +10349,7 @@ void TestQgsProcessing::parameterDatabaseTable() QgsProcessingContext context; // not optional, no default - std::unique_ptr def( new QgsProcessingParameterDatabaseTable( "non_optional", QString(), QString(), QString(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString(), QString(), QVariant(), false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -10463,7 +10463,7 @@ void TestQgsProcessing::parameterFieldMapping() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterFieldMapping( "non_optional", QString(), QStringLiteral( "parent" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), QStringLiteral( "parent" ), false ); QVERIFY( !def->checkValueIsAcceptable( 1 ) ); QVERIFY( !def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -10530,7 +10530,7 @@ void TestQgsProcessing::parameterAggregate() QgsProcessingContext context; // not optional! - std::unique_ptr def( new QgsProcessingParameterAggregate( "non_optional", QString(), QStringLiteral( "parent" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), QStringLiteral( "parent" ), false ); QVERIFY( !def->checkValueIsAcceptable( 1 ) ); QVERIFY( !def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -10624,7 +10624,7 @@ void TestQgsProcessing::parameterTinInputLayers() QgsVectorLayer *vectorLayer = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "PointLayerForTin" ), QStringLiteral( "memory" ) ); project.addMapLayer( vectorLayer ); - std::unique_ptr def( new QgsProcessingParameterTinInputLayers( "tin input layer" ) ); + auto def = std::make_unique( "tin input layer" ); QVERIFY( !def->checkValueIsAcceptable( 1 ) ); QVERIFY( !def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -10778,7 +10778,7 @@ void TestQgsProcessing::parameterMeshDatasetTime() QgsProject project; context.setProject( &project ); - std::unique_ptr def( new QgsProcessingParameterMeshDatasetTime( QStringLiteral( "dataset groups" ), QStringLiteral( "groups" ) ) ); + auto def = std::make_unique( QStringLiteral( "dataset groups" ), QStringLiteral( "groups" ) ); QVERIFY( def->type() == QLatin1String( "meshdatasettime" ) ); QVERIFY( def->checkValueIsAcceptable( QDateTime( QDate( 2020, 01, 01 ), QTime( 10, 0, 0 ) ) ) ); QVERIFY( def->checkValueIsAcceptable( QVariant::fromValue( QDateTime( QDate( 2020, 01, 01 ), QTime( 10, 0, 0 ) ) ).toString() ) ); @@ -10890,7 +10890,7 @@ void TestQgsProcessing::parameterDateTime() QgsProcessingContext context; // not optional, with default - std::unique_ptr def( new QgsProcessingParameterDateTime( "non_optional", QString(), Qgis::ProcessingDateTimeParameterDataType::DateTime, QDateTime( QDate( 2010, 4, 3 ), QTime( 12, 11, 10 ) ), false ) ); + auto def = std::make_unique( "non_optional", QString(), Qgis::ProcessingDateTimeParameterDataType::DateTime, QDateTime( QDate( 2010, 4, 3 ), QTime( 12, 11, 10 ) ), false ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); QVERIFY( !def->checkValueIsAcceptable( "1.1" ) ); QVERIFY( def->checkValueIsAcceptable( QDateTime( QDate( 2020, 2, 2 ), QTime( 0, 0, 0 ) ) ) ); @@ -11280,7 +11280,7 @@ void TestQgsProcessing::parameterDxfLayers() QgsVectorLayer *vectorLayer = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "PointLayer" ), QStringLiteral( "memory" ) ); project.addMapLayer( vectorLayer ); - std::unique_ptr def( new QgsProcessingParameterDxfLayers( "dxf input layer" ) ); + auto def = std::make_unique( "dxf input layer" ); QVERIFY( !def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -11418,7 +11418,7 @@ void TestQgsProcessing::parameterAnnotationLayer() context.setProject( &p ); // not optional, no default - std::unique_ptr def( new QgsProcessingParameterAnnotationLayer( "non_optional", QString(), QVariant(), false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -11598,7 +11598,7 @@ void TestQgsProcessing::parameterPointCloudLayer() context.setProject( &p ); // not optional, with default - std::unique_ptr def( new QgsProcessingParameterPointCloudLayer( "non_optional", QString(), QString( "somelayer" ), false ) ); + auto def = std::make_unique( "non_optional", QString(), QString( "somelayer" ), false ); QVERIFY( !def->checkValueIsAcceptable( false ) ); QVERIFY( !def->checkValueIsAcceptable( true ) ); QVERIFY( !def->checkValueIsAcceptable( 5 ) ); @@ -11748,7 +11748,7 @@ void TestQgsProcessing::parameterPointCloudAttribute() QgsProcessingContext context; // not optional, no default - std::unique_ptr def( new QgsProcessingParameterPointCloudAttribute( "non_optional", QString(), QVariant(), QString(), false, false ) ); + auto def = std::make_unique( "non_optional", QString(), QVariant(), QString(), false, false ); QVERIFY( def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( QStringList() << "a" << "b" ) ); @@ -11982,7 +11982,7 @@ void TestQgsProcessing::parameterAlignRasterLayers() QgsRasterLayer *rasterLayer = new QgsRasterLayer( fi.filePath(), "R1" ); project.addMapLayer( rasterLayer ); - std::unique_ptr def( new QgsProcessingParameterAlignRasterLayers( "align raster layer" ) ); + auto def = std::make_unique( "align raster layer" ); QVERIFY( !def->checkValueIsAcceptable( 1 ) ); QVERIFY( def->checkValueIsAcceptable( "test" ) ); QVERIFY( !def->checkValueIsAcceptable( "" ) ); @@ -12257,7 +12257,7 @@ void TestQgsProcessing::processingFeatureSink() context.setProject( &p ); // first using static string definition - std::unique_ptr def( new QgsProcessingParameterFeatureSink( QStringLiteral( "layer" ) ) ); + auto def = std::make_unique( QStringLiteral( "layer" ) ); QVariantMap params; params.insert( QStringLiteral( "layer" ), QgsProcessingOutputLayerDefinition( "memory:test", nullptr ) ); QString dest; diff --git a/tests/src/analysis/testqgszonalstatistics.cpp b/tests/src/analysis/testqgszonalstatistics.cpp index cbbb3da5099..15b0ad05e2e 100644 --- a/tests/src/analysis/testqgszonalstatistics.cpp +++ b/tests/src/analysis/testqgszonalstatistics.cpp @@ -201,7 +201,7 @@ void TestQgsZonalStatistics::testReprojection() const QString myTestDataPath = myDataPath + "/zonalstatistics/"; // create a reprojected version of the layer - std::unique_ptr vectorLayer( new QgsVectorLayer( myTestDataPath + "polys.shp", QStringLiteral( "poly" ), QStringLiteral( "ogr" ) ) ); + auto vectorLayer = std::make_unique( myTestDataPath + "polys.shp", QStringLiteral( "poly" ), QStringLiteral( "ogr" ) ); std::unique_ptr reprojected( vectorLayer->materialize( QgsFeatureRequest().setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3785" ) ), QgsProject::instance()->transformContext() ) ) ); QCOMPARE( reprojected->featureCount(), vectorLayer->featureCount() ); diff --git a/tests/src/app/testqgsattributetable.cpp b/tests/src/app/testqgsattributetable.cpp index b2fe48e02b9..02afb55c5f9 100644 --- a/tests/src/app/testqgsattributetable.cpp +++ b/tests/src/app/testqgsattributetable.cpp @@ -113,7 +113,7 @@ void TestQgsAttributeTable::testFieldCalculation() //test field calculation //create a temporary layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -131,7 +131,7 @@ void TestQgsAttributeTable::testFieldCalculation() QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Meters ); // run length calculation - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + auto dlg = std::make_unique( tempLayer.get() ); tempLayer->startEditing(); dlg->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$length" ) ); tempLayer->commitChanges(); @@ -144,7 +144,7 @@ void TestQgsAttributeTable::testFieldCalculation() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Feet ); - std::unique_ptr dlg2( new QgsAttributeTableDialog( tempLayer.get() ) ); + auto dlg2 = std::make_unique( tempLayer.get() ); tempLayer->startEditing(); dlg2->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$length" ) ); tempLayer->commitChanges(); @@ -160,7 +160,7 @@ void TestQgsAttributeTable::testFieldCalculationArea() //test $area field calculation //create a temporary layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -181,7 +181,7 @@ void TestQgsAttributeTable::testFieldCalculationArea() QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMeters ); // run area calculation - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + auto dlg = std::make_unique( tempLayer.get() ); tempLayer->startEditing(); dlg->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$area" ) ); tempLayer->commitChanges(); @@ -194,7 +194,7 @@ void TestQgsAttributeTable::testFieldCalculationArea() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMiles ); - std::unique_ptr dlg2( new QgsAttributeTableDialog( tempLayer.get() ) ); + auto dlg2 = std::make_unique( tempLayer.get() ); tempLayer->startEditing(); dlg2->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$area" ) ); tempLayer->commitChanges(); @@ -210,10 +210,10 @@ void TestQgsAttributeTable::testNoGeom() const QgsSettings s; //test that by default the attribute table DOESN'T fetch geometries (because performance) - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ) ); + auto dlg = std::make_unique( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ); QVERIFY( !dlg->mMainView->masterModel()->layerCache()->cacheGeometry() ); QVERIFY( dlg->mMainView->masterModel()->request().flags() & Qgis::FeatureRequestFlag::NoGeometry ); @@ -238,7 +238,7 @@ void TestQgsAttributeTable::testNoGeom() void TestQgsAttributeTable::testVisibleTemporal() { // test attribute table opening in show feature visible mode - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsPolylineXY line; @@ -269,7 +269,7 @@ void TestQgsAttributeTable::testVisibleTemporal() mQgisApp->mapCanvas()->setExtent( QgsRectangle( -1, -1, 1, 1 ) ); mQgisApp->mapCanvas()->setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 2, 1 ), QTime( 0, 0, 0 ) ) ) ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowVisible ) ); + auto dlg = std::make_unique( tempLayer.get(), QgsAttributeTableFilterModel::ShowVisible ); // feature id 2 is filtered out due to being out of temporal range // feature id 3 is filtered out due to being out of visible extent @@ -279,7 +279,7 @@ void TestQgsAttributeTable::testVisibleTemporal() void TestQgsAttributeTable::testSelected() { // test attribute table opening in show selected mode - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); const QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -287,7 +287,7 @@ void TestQgsAttributeTable::testSelected() const QgsFeature f3( tempLayer->dataProvider()->fields(), 3 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowSelected ) ); + auto dlg = std::make_unique( tempLayer.get(), QgsAttributeTableFilterModel::ShowSelected ); QVERIFY( !dlg->mMainView->masterModel()->layerCache()->cacheGeometry() ); //should be nothing - because no selection! @@ -313,7 +313,7 @@ void TestQgsAttributeTable::testSelected() void TestQgsAttributeTable::testEdited() { // test attribute table opening in edited features mode - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); const QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -321,7 +321,7 @@ void TestQgsAttributeTable::testEdited() const QgsFeature f3( tempLayer->dataProvider()->fields(), 3 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowEdited ) ); + auto dlg = std::make_unique( tempLayer.get(), QgsAttributeTableFilterModel::ShowEdited ); QVERIFY( !dlg->mMainView->masterModel()->layerCache()->cacheGeometry() ); //should be nothing - because no edited features! @@ -351,7 +351,7 @@ void TestQgsAttributeTable::testEdited() void TestQgsAttributeTable::testSelectedOnTop() { - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -365,7 +365,7 @@ void TestQgsAttributeTable::testSelectedOnTop() f3.setAttribute( 1, 5.0 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + auto dlg = std::make_unique( tempLayer.get() ); dlg->mMainView->setSortExpression( "pk" ); QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); @@ -414,7 +414,7 @@ void TestQgsAttributeTable::testSelectedOnTop() void TestQgsAttributeTable::testSortByDisplayExpression() { - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -428,7 +428,7 @@ void TestQgsAttributeTable::testSortByDisplayExpression() f3.setAttribute( 1, 5.0 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + auto dlg = std::make_unique( tempLayer.get() ); dlg->mMainView->mFeatureListView->setDisplayExpression( "pk" ); QgsFeatureListModel *listModel = dlg->mMainView->mFeatureListModel; @@ -448,7 +448,7 @@ void TestQgsAttributeTable::testSortNumbers() { QLocale::setDefault( QLocale::Italian ); - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -462,7 +462,7 @@ void TestQgsAttributeTable::testSortNumbers() f3.setAttribute( 1, 10.0001 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + auto dlg = std::make_unique( tempLayer.get() ); QgsAttributeTableConfig cfg; cfg.setSortExpression( QStringLiteral( R"("col1")" ) ); @@ -504,7 +504,7 @@ void TestQgsAttributeTable::testStartMultiEditNoChanges() layer->selectAll(); - std::unique_ptr dlg( new QgsAttributeTableDialog( layer.get() ) ); + auto dlg = std::make_unique( layer.get() ); for ( int i = 0; i < 10; ++i ) { @@ -551,7 +551,7 @@ void TestQgsAttributeTable::testMultiEditMakeUncommittedChanges() layer->selectAll(); - std::unique_ptr dlg( new QgsAttributeTableDialog( layer.get() ) ); + auto dlg = std::make_unique( layer.get() ); dlg->mMainView->setCurrentEditSelection( { ft2.id() } ); layer->startEditing(); @@ -574,13 +574,13 @@ void TestQgsAttributeTable::testRegression15974() { // Test duplicated rows in attribute table + two crashes. const QString path = QDir::tempPath() + "/testshp15974.shp"; - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = QStringLiteral( "system" ); saveOptions.driverName = QStringLiteral( "ESRI Shapefile" ); QgsVectorFileWriter::writeAsVectorFormatV3( tempLayer.get(), path, tempLayer->transformContext(), saveOptions ); - std::unique_ptr shpLayer( new QgsVectorLayer( path, QStringLiteral( "test" ), QStringLiteral( "ogr" ) ) ); + auto shpLayer = std::make_unique( path, QStringLiteral( "test" ), QStringLiteral( "ogr" ) ); QgsFeature f1( shpLayer->dataProvider()->fields(), 1 ); QgsGeometry geom; geom = QgsGeometry::fromWkt( QStringLiteral( "polygon((0 0, 0 1, 1 1, 1 0, 0 0))" ) ); @@ -592,7 +592,7 @@ void TestQgsAttributeTable::testRegression15974() f3.setGeometry( geom ); QVERIFY( shpLayer->startEditing() ); QVERIFY( shpLayer->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr dlg( new QgsAttributeTableDialog( shpLayer.get() ) ); + auto dlg = std::make_unique( shpLayer.get() ); QCOMPARE( shpLayer->featureCount(), 3L ); mQgisApp->saveEdits( shpLayer.get() ); QCOMPARE( shpLayer->featureCount(), 3L ); @@ -608,7 +608,7 @@ void TestQgsAttributeTable::testRegression15974() void TestQgsAttributeTable::testOrderColumn() { - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -617,7 +617,7 @@ void TestQgsAttributeTable::testOrderColumn() f1.setAttribute( 2, 7 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ) ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + auto dlg = std::make_unique( tempLayer.get() ); // Issue https://github.com/qgis/QGIS/issues/28493 // When we reorder column (last column becomes first column), and we select an entire row @@ -661,7 +661,7 @@ void TestQgsAttributeTable::testOrderColumn() void TestQgsAttributeTable::testFilteredFeatures() { - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -679,7 +679,7 @@ void TestQgsAttributeTable::testFilteredFeatures() QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ) ); + auto dlg = std::make_unique( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ); QEventLoop loop; connect( qobject_cast( dlg->mMainView->mFilterModel ), &QgsAttributeTableFilterModel::featuresFiltered, &loop, &QEventLoop::quit ); @@ -744,7 +744,7 @@ void TestQgsAttributeTable::testFilteredFeatures() void TestQgsAttributeTable::testCopySelectedRows() { - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -757,7 +757,7 @@ void TestQgsAttributeTable::testCopySelectedRows() QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 ) ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ) ); + auto dlg = std::make_unique( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ); tempLayer->selectByIds( QgsFeatureIds() << 1 << 2 ); @@ -787,7 +787,7 @@ void TestQgsAttributeTable::testCopySelectedRows() void TestQgsAttributeTable::testOpenWithFilterExpression() { // test attribute table opening in show feature visible mode - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsPolylineXY line; @@ -808,7 +808,7 @@ void TestQgsAttributeTable::testOpenWithFilterExpression() QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); const QString filterExpression = QStringLiteral( "col1 < to_date('2020-02-03')" ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowFilteredList, nullptr, Qt::Window, nullptr, filterExpression ) ); + auto dlg = std::make_unique( tempLayer.get(), QgsAttributeTableFilterModel::ShowFilteredList, nullptr, Qt::Window, nullptr, filterExpression ); // feature id 2 is filtered out due not matching the provided filter expression QCOMPARE( dlg->mMainView->filteredFeatures(), QgsFeatureIds() << 1 << 3 ); @@ -816,7 +816,7 @@ void TestQgsAttributeTable::testOpenWithFilterExpression() void TestQgsAttributeTable::testInvalidView() { - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsPolylineXY line; @@ -840,7 +840,7 @@ void TestQgsAttributeTable::testInvalidView() tempLayer->setConstraintExpression( 1, QStringLiteral( "col1 >= to_date('2020-02-03')" ) ); tempLayer->setFieldConstraint( 1, QgsFieldConstraints::ConstraintExpression, QgsFieldConstraints::ConstraintStrengthHard ); - std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll, nullptr, Qt::Window, nullptr, filterExpression ) ); + auto dlg = std::make_unique( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll, nullptr, Qt::Window, nullptr, filterExpression ); dlg->mFeatureFilterWidget->filterInvalid(); // feature id 2 is filtered out due not matching the provided filter expression @@ -867,7 +867,7 @@ void TestQgsAttributeTable::testEnsureEditSelection() layer->removeSelection(); - std::unique_ptr dlg( new QgsAttributeTableDialog( layer.get() ) ); + auto dlg = std::make_unique( layer.get() ); //since the update is done by timer, we have to wait (at least one millisecond) or until the current edit selection changed qRegisterMetaType( "QgsFeature&" ); @@ -919,7 +919,7 @@ void TestQgsAttributeTable::testFetchAllAttributes() config.setColumnHidden( 1, true ); layer->setAttributeTableConfig( config ); - std::unique_ptr dlg( new QgsAttributeTableDialog( layer.get() ) ); + auto dlg = std::make_unique( layer.get() ); QCOMPARE( dlg->mMainView->masterModel()->data( dlg->mMainView->masterModel()->index( 0, 0 ), Qt::DisplayRole ).toString(), "Jet" ); QCOMPARE( dlg->mMainView->masterModel()->data( dlg->mMainView->masterModel()->index( 0, 1 ), Qt::DisplayRole ).toString(), "90" ); diff --git a/tests/src/app/testqgsfieldcalculator.cpp b/tests/src/app/testqgsfieldcalculator.cpp index f121d1d6b17..229a0536f72 100644 --- a/tests/src/app/testqgsfieldcalculator.cpp +++ b/tests/src/app/testqgsfieldcalculator.cpp @@ -68,7 +68,7 @@ void TestQgsFieldCalculator::testLengthCalculations() //test length calculation respects ellipsoid and project distance units //create a temporary layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -87,7 +87,7 @@ void TestQgsFieldCalculator::testLengthCalculations() // run length calculation tempLayer->startEditing(); - std::unique_ptr calc( new QgsFieldCalculator( tempLayer.get() ) ); + auto calc = std::make_unique( tempLayer.get() ); // this next part is fragile, and may need to be modified if the dialog changes: calc->mUpdateExistingGroupBox->setChecked( true ); @@ -107,7 +107,7 @@ void TestQgsFieldCalculator::testLengthCalculations() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Feet ); tempLayer->startEditing(); - std::unique_ptr calc2( new QgsFieldCalculator( tempLayer.get() ) ); + auto calc2 = std::make_unique( tempLayer.get() ); calc2->mUpdateExistingGroupBox->setChecked( true ); calc2->mExistingFieldComboBox->setCurrentIndex( 1 ); calc2->builder->setExpressionText( QStringLiteral( "$length" ) ); @@ -125,7 +125,7 @@ void TestQgsFieldCalculator::testAreaCalculations() //test area calculation respects ellipsoid and project area units //create a temporary layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -147,7 +147,7 @@ void TestQgsFieldCalculator::testAreaCalculations() // run area calculation tempLayer->startEditing(); - std::unique_ptr calc( new QgsFieldCalculator( tempLayer.get() ) ); + auto calc = std::make_unique( tempLayer.get() ); // this next part is fragile, and may need to be modified if the dialog changes: calc->mUpdateExistingGroupBox->setChecked( true ); @@ -167,7 +167,7 @@ void TestQgsFieldCalculator::testAreaCalculations() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMiles ); tempLayer->startEditing(); - std::unique_ptr calc2( new QgsFieldCalculator( tempLayer.get() ) ); + auto calc2 = std::make_unique( tempLayer.get() ); calc2->mUpdateExistingGroupBox->setChecked( true ); calc2->mExistingFieldComboBox->setCurrentIndex( 1 ); calc2->builder->setExpressionText( QStringLiteral( "$area" ) ); diff --git a/tests/src/app/testqgsidentify.cpp b/tests/src/app/testqgsidentify.cpp index cf706298149..9a339eea081 100644 --- a/tests/src/app/testqgsidentify.cpp +++ b/tests/src/app/testqgsidentify.cpp @@ -186,7 +186,7 @@ void TestQgsIdentify::doAction() void TestQgsIdentify::clickxy() { // create temp layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3111" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "Point?crs=epsg:3111" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); // add feature @@ -233,7 +233,7 @@ void TestQgsIdentify::closestPoint() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineStringZM?crs=epsg:3111&field=pk:int&field=col1:double&field=url:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineStringZM?crs=epsg:3111&field=pk:int&field=col1:double&field=url:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -255,7 +255,7 @@ void TestQgsIdentify::closestPoint() QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 2484587, 2399800 ); - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); QgsIdentifyResultsDialog *dlg = action->resultsDialog(); //check that closest point attributes are present @@ -306,7 +306,7 @@ void TestQgsIdentify::closestPoint() // polygons //create a temporary layer - std::unique_ptr tempLayer2( new QgsVectorLayer( QStringLiteral( "PolygonZM?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer2 = std::make_unique( QStringLiteral( "PolygonZM?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer2->isValid() ); f1 = QgsFeature( tempLayer2->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -337,7 +337,7 @@ void TestQgsIdentify::lengthCalculation() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -361,7 +361,7 @@ void TestQgsIdentify::lengthCalculation() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 2484588, 2425722 ); - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); QString derivedLength = result.at( 0 ).mDerivedAttributes[tr( "Length (Ellipsoidal — WGS84)" )]; @@ -460,7 +460,7 @@ void TestQgsIdentify::perimeterCalculation() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -486,7 +486,7 @@ void TestQgsIdentify::perimeterCalculation() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 2484588, 2425722 ); - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); QString derivedPerimeter = result.at( 0 ).mDerivedAttributes[tr( "Perimeter (Ellipsoidal — WGS84)" )]; @@ -537,7 +537,7 @@ void TestQgsIdentify::areaCalculation() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -564,7 +564,7 @@ void TestQgsIdentify::areaCalculation() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 2484588, 2425722 ); - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); QString derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area (Ellipsoidal — WGS84)" )]; @@ -613,7 +613,7 @@ void TestQgsIdentify::areaCalculation() // private QList TestQgsIdentify::testIdentifyRaster( QgsRasterLayer *layer, double xGeoref, double yGeoref, bool roundToCanvasPixels ) { - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); QgsIdentifyContext identifyContext; @@ -629,7 +629,7 @@ QList TestQgsIdentify::testIdentifyRaster( Q // private QList TestQgsIdentify::testIdentifyMesh( QgsMeshLayer *layer, double xGeoref, double yGeoref ) { - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); //check that closest point attributes are present QgsIdentifyContext identifyContext; @@ -643,7 +643,7 @@ QList TestQgsIdentify::testIdentifyMesh( Qgs QList TestQgsIdentify::testIdentifyVector( QgsVectorLayer *layer, double xGeoref, double yGeoref ) { - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); QgsIdentifyContext identifyContext; if ( canvas->mapSettings().isTemporal() ) @@ -656,7 +656,7 @@ QList QList TestQgsIdentify::testIdentifyVectorTile( QgsVectorTileLayer *layer, double xGeoref, double yGeoref ) { - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); QgsIdentifyContext identifyContext; if ( canvas->mapSettings().isTemporal() ) @@ -696,7 +696,7 @@ void TestQgsIdentify::identifyRasterFloat32() // By default the QgsRasterLayer forces AAIGRID_DATATYPE=Float64 CPLSetConfigOption( "AAIGRID_DATATYPE", "Float32" ); - std::unique_ptr tempLayer( new QgsRasterLayer( raster ) ); + auto tempLayer = std::make_unique( raster ); CPLSetConfigOption( "AAIGRID_DATATYPE", nullptr ); QVERIFY( tempLayer->isValid() ); @@ -728,7 +728,7 @@ void TestQgsIdentify::identifyRasterFloat64() { //create a temporary layer const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/test.asc"; - std::unique_ptr tempLayer( new QgsRasterLayer( raster ) ); + auto tempLayer = std::make_unique( raster ); QVERIFY( tempLayer->isValid() ); canvas->setExtent( QgsRectangle( 0, 0, 7, 1 ) ); @@ -751,7 +751,7 @@ void TestQgsIdentify::identifyRasterFloat64() void TestQgsIdentify::identifyRasterDerivedAttributes() { const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/dem.tif"; - std::unique_ptr tempLayer( new QgsRasterLayer( raster ) ); + auto tempLayer = std::make_unique( raster ); QVERIFY( tempLayer->isValid() ); const QgsRectangle layerExtent = tempLayer->extent(); @@ -958,7 +958,7 @@ void TestQgsIdentify::identifyVectorTile() void TestQgsIdentify::identifyInvalidPolygons() { //create a temporary layer - std::unique_ptr memoryLayer( new QgsVectorLayer( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto memoryLayer = std::make_unique( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature f1( memoryLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -1170,7 +1170,7 @@ void TestQgsIdentify::testRelations() void TestQgsIdentify::testPointZ() { - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "PointZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "PointZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QCOMPARE( tempLayer->crs3D().horizontalCrs().authid(), QStringLiteral( "EPSG:4979" ) ); @@ -1189,7 +1189,7 @@ void TestQgsIdentify::testPointZ() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 134.445567853, -23.445567853 ); - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); QList result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); double z4979 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Z (EPSG:4979 - WGS 84)" )].toDouble(); @@ -1200,7 +1200,7 @@ void TestQgsIdentify::testPointZ() void TestQgsIdentify::testLineStringZ() { - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineStringZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "LineStringZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QCOMPARE( tempLayer->crs3D().horizontalCrs().authid(), QStringLiteral( "EPSG:4979" ) ); @@ -1220,7 +1220,7 @@ void TestQgsIdentify::testLineStringZ() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 136.46, -23.445567853 ); - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); QList result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); double interpolatedZ4979 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Interpolated Z (EPSG:4979 - WGS 84)" )].toDouble(); @@ -1235,7 +1235,7 @@ void TestQgsIdentify::testLineStringZ() void TestQgsIdentify::testPolygonZ() { - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "PolygonZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "PolygonZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); QCOMPARE( tempLayer->crs3D().horizontalCrs().authid(), QStringLiteral( "EPSG:4979" ) ); @@ -1255,7 +1255,7 @@ void TestQgsIdentify::testPolygonZ() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 136.46, -23.445567853 ); - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); QList result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); double interpolatedZ4979 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Interpolated Z (EPSG:4979 - WGS 84)" )].toDouble(); @@ -1288,7 +1288,7 @@ void TestQgsIdentify::identifyPointCloud() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 7.42006, 2.74911 ); - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); QList result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << pointCloud.get() ); QCOMPARE( result.length(), 1 ); double z4979 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Z (EPSG:4979 - WGS 84)" )].toDouble(); @@ -1318,7 +1318,7 @@ void TestQgsIdentify::identifyVirtualPointCloud() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 498065.23, 7050992.90 ); - std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + auto action = std::make_unique( canvas ); QList result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << pointCloud.get() ); QCOMPARE( result.length(), 1 ); double z = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Z" )].toDouble(); diff --git a/tests/src/app/testqgsmaptoollabel.cpp b/tests/src/app/testqgsmaptoollabel.cpp index a9dc51780b4..67f11348f8b 100644 --- a/tests/src/app/testqgsmaptoollabel.cpp +++ b/tests/src/app/testqgsmaptoollabel.cpp @@ -95,7 +95,7 @@ class TestQgsMapToolLabel : public QObject QCOMPARE( canvas->mapSettings().outputSize(), QSize( 500, 500 ) ); QCOMPARE( canvas->mapSettings().visibleExtent(), QgsRectangle( -1, -1, 4, 4 ) ); - std::unique_ptr tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); + auto tool = std::make_unique( canvas.get(), advancedDigitizingDockWidget.get() ); // no labels yet QgsPointXY pt; @@ -261,7 +261,7 @@ class TestQgsMapToolLabel : public QObject QCOMPARE( canvas->mapSettings().outputSize(), QSize( 500, 500 ) ); QCOMPARE( canvas->mapSettings().visibleExtent(), QgsRectangle( -1, -1, 4, 4 ) ); - std::unique_ptr tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); + auto tool = std::make_unique( canvas.get(), advancedDigitizingDockWidget.get() ); // add some labels QgsPalLayerSettings pls1; @@ -405,7 +405,7 @@ class TestQgsMapToolLabel : public QObject QCOMPARE( canvas->mapSettings().outputSize(), QSize( 500, 500 ) ); QCOMPARE( canvas->mapSettings().visibleExtent(), QgsRectangle( -1, -1, 4, 4 ) ); - std::unique_ptr tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); + auto tool = std::make_unique( canvas.get(), advancedDigitizingDockWidget.get() ); // add some labels QgsPalLayerSettings pls1; @@ -485,7 +485,7 @@ class TestQgsMapToolLabel : public QObject canvas->setLayers( QList() << vl1 ); const std::unique_ptr advancedDigitizingDockWidget = std::make_unique( canvas.get() ); - std::unique_ptr tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); + auto tool = std::make_unique( canvas.get(), advancedDigitizingDockWidget.get() ); QgsExpressionContextUtils::setProjectVariable( QgsProject::instance(), QStringLiteral( "var_1" ), QStringLiteral( "1" ) ); diff --git a/tests/src/app/testqgsmaptoolreshape.cpp b/tests/src/app/testqgsmaptoolreshape.cpp index 4a9cbbcf715..a8b52f92ebd 100644 --- a/tests/src/app/testqgsmaptoolreshape.cpp +++ b/tests/src/app/testqgsmaptoolreshape.cpp @@ -381,7 +381,7 @@ void TestQgsMapToolReshape::testWithTracing() QgsProject::instance()->addMapLayers( QList() << mLayerTopo ); mCanvas->setLayers( QList() << mLayerTopo ); - std::unique_ptr tracer( new QgsMapCanvasTracer( mCanvas, nullptr ) ); + auto tracer = std::make_unique( mCanvas, nullptr ); const bool topologicalEditing = QgsProject::instance()->topologicalEditing(); QgsProject::instance()->setTopologicalEditing( true ); diff --git a/tests/src/app/testqgsmaptoolreverseline.cpp b/tests/src/app/testqgsmaptoolreverseline.cpp index 413dba1c66e..69bb3c0b3e7 100644 --- a/tests/src/app/testqgsmaptoolreverseline.cpp +++ b/tests/src/app/testqgsmaptoolreverseline.cpp @@ -70,7 +70,7 @@ void TestQgsMapToolReverseLine::cleanupTestCase() void TestQgsMapToolReverseLine::testReverseCurve() { //create a temporary layer - std::unique_ptr memoryLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto memoryLayer = std::make_unique( QStringLiteral( "LineString?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature curve( memoryLayer->dataProvider()->fields(), 1 ); @@ -84,7 +84,7 @@ void TestQgsMapToolReverseLine::testReverseCurve() mCanvas->setLayers( QList() << memoryLayer.get() ); mCanvas->setCurrentLayer( memoryLayer.get() ); - std::unique_ptr tool( new QgsMapToolReverseLine( mCanvas ) ); + auto tool = std::make_unique( mCanvas ); memoryLayer->startEditing(); const QgsPointXY mapPoint = mCanvas->getCoordinateTransform()->transform( 5, 5 ); @@ -106,7 +106,7 @@ void TestQgsMapToolReverseLine::testReverseCurve() void TestQgsMapToolReverseLine::testReverseLineString() { //create a temporary layer - std::unique_ptr memoryLayer( new QgsVectorLayer( QStringLiteral( "LineStringZ?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto memoryLayer = std::make_unique( QStringLiteral( "LineStringZ?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature line( memoryLayer->dataProvider()->fields(), 1 ); @@ -120,7 +120,7 @@ void TestQgsMapToolReverseLine::testReverseLineString() mCanvas->setCurrentLayer( memoryLayer.get() ); - std::unique_ptr tool( new QgsMapToolReverseLine( mCanvas ) ); + auto tool = std::make_unique( mCanvas ); memoryLayer->startEditing(); const QgsPointXY mapPoint = mCanvas->getCoordinateTransform()->transform( 6, 6 ); const std::unique_ptr event( new QgsMapMouseEvent( @@ -143,7 +143,7 @@ void TestQgsMapToolReverseLine::testReverseLineString() void TestQgsMapToolReverseLine::testReverseMultiLineString() { //create a temporary layer - std::unique_ptr memoryLayer( new QgsVectorLayer( QStringLiteral( "MultiLineStringZ?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto memoryLayer = std::make_unique( QStringLiteral( "MultiLineStringZ?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature multi( memoryLayer->dataProvider()->fields(), 1 ); @@ -156,7 +156,7 @@ void TestQgsMapToolReverseLine::testReverseMultiLineString() mCanvas->setLayers( QList() << memoryLayer.get() ); mCanvas->setCurrentLayer( memoryLayer.get() ); - std::unique_ptr tool( new QgsMapToolReverseLine( mCanvas ) ); + auto tool = std::make_unique( mCanvas ); memoryLayer->startEditing(); QgsPointXY mapPoint = mCanvas->getCoordinateTransform()->transform( 6, 6 ); diff --git a/tests/src/app/testqgsmaptoolselect.cpp b/tests/src/app/testqgsmaptoolselect.cpp index 6c3ffd26ef7..7eae43e577a 100644 --- a/tests/src/app/testqgsmaptoolselect.cpp +++ b/tests/src/app/testqgsmaptoolselect.cpp @@ -106,7 +106,7 @@ void TestQgsMapToolSelect::cleanup() QgsFeatureList TestQgsMapToolSelect::testSelectVector( QgsVectorLayer *layer, double xGeoref, double yGeoref ) { - std::unique_ptr tool( new QgsMapToolSelect( canvas ) ); + auto tool = std::make_unique( canvas ); const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); // make given vector layer current @@ -128,7 +128,7 @@ QgsFeatureList void TestQgsMapToolSelect::selectInvalidPolygons() { //create a temporary layer - std::unique_ptr memoryLayer( new QgsVectorLayer( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto memoryLayer = std::make_unique( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature f1( memoryLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); diff --git a/tests/src/app/testqgsmaptooltrimextendfeature.cpp b/tests/src/app/testqgsmaptooltrimextendfeature.cpp index 3716e244661..57e0583dc7e 100644 --- a/tests/src/app/testqgsmaptooltrimextendfeature.cpp +++ b/tests/src/app/testqgsmaptooltrimextendfeature.cpp @@ -234,7 +234,7 @@ class TestQgsMapToolTrimExtendFeature : public QObject // | + (2,1) | // (0,0) +-------------------+ (3,0) mCanvas->setCurrentLayer( vlPolygon.get() ); - std::unique_ptr tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); + auto tool = std::make_unique( mCanvas ); vlPolygon->startEditing(); // Limit @@ -298,7 +298,7 @@ class TestQgsMapToolTrimExtendFeature : public QObject * | */ mCanvas->setCurrentLayer( vlMultiLine.get() ); - std::unique_ptr tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); + auto tool = std::make_unique( mCanvas ); vlMultiLine->startEditing(); // Limit @@ -450,7 +450,7 @@ class TestQgsMapToolTrimExtendFeature : public QObject (0 5 100) (3 5 5) */ mCanvas->setCurrentLayer( vlLineZ.get() ); - std::unique_ptr tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); + auto tool = std::make_unique( mCanvas ); vlLineZ->startEditing(); // Limit @@ -507,7 +507,7 @@ class TestQgsMapToolTrimExtendFeature : public QObject QgsProject::instance()->setTopologicalEditing( true ); mCanvas->setCurrentLayer( vlTopoEdit.get() ); - std::unique_ptr tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); + auto tool = std::make_unique( mCanvas ); vlTopoLimit->startEditing(); vlTopoEdit->startEditing(); @@ -572,7 +572,7 @@ class TestQgsMapToolTrimExtendFeature : public QObject * + (5, 0) */ mCanvas->setCurrentLayer( vlMultiExtend.get() ); - std::unique_ptr tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); + auto tool = std::make_unique( mCanvas ); vlMultiExtend->startEditing(); // Limit diff --git a/tests/src/app/testqgsmeasuretool.cpp b/tests/src/app/testqgsmeasuretool.cpp index ebbd622b3c6..a45b4d40021 100644 --- a/tests/src/app/testqgsmeasuretool.cpp +++ b/tests/src/app/testqgsmeasuretool.cpp @@ -93,8 +93,8 @@ void TestQgsMeasureTool::testLengthCalculationCartesian() QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Meters ); // run length calculation - std::unique_ptr tool( new QgsMeasureTool( mCanvas, false ) ); - std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); + auto tool = std::make_unique( mCanvas, false ); + auto dlg = std::make_unique( tool.get() ); dlg->mCartesian->setChecked( true ); @@ -112,8 +112,8 @@ void TestQgsMeasureTool::testLengthCalculationCartesian() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Feet ); - std::unique_ptr tool2( new QgsMeasureTool( mCanvas, false ) ); - std::unique_ptr dlg2( new QgsMeasureDialog( tool2.get() ) ); + auto tool2 = std::make_unique( mCanvas, false ); + auto dlg2 = std::make_unique( tool2.get() ); dlg2->mCartesian->setChecked( true ); tool2->restart(); @@ -160,8 +160,8 @@ void TestQgsMeasureTool::testLengthCalculationProjected() QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Meters ); // run length calculation - std::unique_ptr tool( new QgsMeasureTool( mCanvas, false ) ); - std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); + auto tool = std::make_unique( mCanvas, false ); + auto dlg = std::make_unique( tool.get() ); dlg->mEllipsoidal->setChecked( true ); tool->restart(); @@ -178,8 +178,8 @@ void TestQgsMeasureTool::testLengthCalculationProjected() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Feet ); - std::unique_ptr tool2( new QgsMeasureTool( mCanvas, false ) ); - std::unique_ptr dlg2( new QgsMeasureDialog( tool2.get() ) ); + auto tool2 = std::make_unique( mCanvas, false ); + auto dlg2 = std::make_unique( tool2.get() ); dlg2->mEllipsoidal->setChecked( true ); tool2->restart(); @@ -225,8 +225,8 @@ void TestQgsMeasureTool::testLengthCalculationNoCrs() QgsProject::instance()->setCrs( QgsCoordinateReferenceSystem() ); // run length calculation - std::unique_ptr tool( new QgsMeasureTool( mCanvas, false ) ); - std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); + auto tool = std::make_unique( mCanvas, false ); + auto dlg = std::make_unique( tool.get() ); tool->restart(); tool->addPoint( QgsPointXY( 2484588, 2425722 ) ); @@ -255,8 +255,8 @@ void TestQgsMeasureTool::testAreaCalculationCartesian() QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMeters ); // run length calculation - std::unique_ptr tool( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); + auto tool = std::make_unique( mCanvas, true ); + auto dlg = std::make_unique( tool.get() ); dlg->mCartesian->setChecked( true ); @@ -276,8 +276,8 @@ void TestQgsMeasureTool::testAreaCalculationCartesian() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMiles ); - std::unique_ptr tool2( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr dlg2( new QgsMeasureDialog( tool2.get() ) ); + auto tool2 = std::make_unique( mCanvas, true ); + auto dlg2 = std::make_unique( tool2.get() ); dlg2->mCartesian->setChecked( true ); tool2->restart(); @@ -309,8 +309,8 @@ void TestQgsMeasureTool::testAreaCalculationProjected() QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMeters ); // run length calculation - std::unique_ptr tool( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); + auto tool = std::make_unique( mCanvas, true ); + auto dlg = std::make_unique( tool.get() ); dlg->mEllipsoidal->setChecked( true ); @@ -330,8 +330,8 @@ void TestQgsMeasureTool::testAreaCalculationProjected() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMiles ); - std::unique_ptr tool2( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr dlg2( new QgsMeasureDialog( tool2.get() ) ); + auto tool2 = std::make_unique( mCanvas, true ); + auto dlg2 = std::make_unique( tool2.get() ); dlg2->mEllipsoidal->setChecked( true ); @@ -358,7 +358,7 @@ void TestQgsMeasureTool::degreeDecimalPlaces() s.setValue( QStringLiteral( "qgis/measure/decimalplaces" ), 3 ); const std::unique_ptr tool( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); + auto dlg = std::make_unique( tool.get() ); QCOMPARE( dlg->formatDistance( 11, false ), QString( "11.000 deg" ) ); QCOMPARE( dlg->formatDistance( 0.005, false ), QString( "0.005 deg" ) ); @@ -378,8 +378,8 @@ void TestQgsMeasureTool::testToolDesactivationNoExtraPoint() QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMeters ); // run length calculation - std::unique_ptr tool( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); + auto tool = std::make_unique( mCanvas, true ); + auto dlg = std::make_unique( tool.get() ); dlg->mEllipsoidal->setChecked( true ); diff --git a/tests/src/app/testqgsmeshcalculatordialog.cpp b/tests/src/app/testqgsmeshcalculatordialog.cpp index f8aa9035761..0a746336434 100644 --- a/tests/src/app/testqgsmeshcalculatordialog.cpp +++ b/tests/src/app/testqgsmeshcalculatordialog.cpp @@ -85,7 +85,7 @@ void TestQgsMeshCalculatorDialog::testCalc() if ( !QgsTest::runFlakyTests() ) QSKIP( "This test is disabled on Travis CI environment" ); - std::unique_ptr dialog( new QgsMeshCalculatorDialog( mpMeshLayer ) ); + auto dialog = std::make_unique( mpMeshLayer ); const int groupCount = mpMeshLayer->dataProvider()->datasetGroupCount(); diff --git a/tests/src/app/testqgsprojectproperties.cpp b/tests/src/app/testqgsprojectproperties.cpp index 530276b4c44..f2fd4f4791a 100644 --- a/tests/src/app/testqgsprojectproperties.cpp +++ b/tests/src/app/testqgsprojectproperties.cpp @@ -76,7 +76,7 @@ void TestQgsProjectProperties::cleanupTestCase() void TestQgsProjectProperties::testProjectPropertiesDirty() { // create a temporary layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "none?field=code:int&field=regular:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "none?field=code:int&field=regular:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); // add layer to project, to insure presence of layer-related project settings diff --git a/tests/src/app/testqgsvectorlayersaveasdialog.cpp b/tests/src/app/testqgsvectorlayersaveasdialog.cpp index 9a6883af080..0b31c4fb968 100644 --- a/tests/src/app/testqgsvectorlayersaveasdialog.cpp +++ b/tests/src/app/testqgsvectorlayersaveasdialog.cpp @@ -69,7 +69,7 @@ void TestQgsVectorLayerSaveAsDialog::cleanupTestCase() void TestQgsVectorLayerSaveAsDialog::testAttributesAsDisplayedValues() { //create a temporary layer - std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "none?field=code:int&field=regular:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto tempLayer = std::make_unique( QStringLiteral( "none?field=code:int&field=regular:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); // Assign a custom CRS to the layer diff --git a/tests/src/core/geometry/testqgscircle.cpp b/tests/src/core/geometry/testqgscircle.cpp index e76dc8b3f1d..63d6770cc82 100644 --- a/tests/src/core/geometry/testqgscircle.cpp +++ b/tests/src/core/geometry/testqgscircle.cpp @@ -393,7 +393,7 @@ void TestQgsCircle::innerTangents() void TestQgsCircle::toPolygon() { QgsPointSequence pts; - std::unique_ptr pol( new QgsPolygon() ); + auto pol = std::make_unique(); pol.reset( QgsCircle( QgsPoint( 0, 0 ), 5 ).toPolygon( 4 ) ); @@ -413,7 +413,7 @@ void TestQgsCircle::toPolygon() void TestQgsCircle::toPolygonoOriented() { QgsPointSequence pts; - std::unique_ptr pol( new QgsPolygon() ); + auto pol = std::make_unique(); double val = 5 * std::sin( M_PI / 4 ); diff --git a/tests/src/core/geometry/testqgscircularstring.cpp b/tests/src/core/geometry/testqgscircularstring.cpp index e5a5733f185..ff9b768a683 100644 --- a/tests/src/core/geometry/testqgscircularstring.cpp +++ b/tests/src/core/geometry/testqgscircularstring.cpp @@ -2370,7 +2370,7 @@ void TestQgsCircularString::append() QVERIFY( cs.isEmpty() ); QCOMPARE( cs.numPoints(), 0 ); - std::unique_ptr toAppend( new QgsCircularString() ); + auto toAppend = std::make_unique(); cs.append( toAppend.get() ); QVERIFY( cs.isEmpty() ); @@ -2428,7 +2428,7 @@ void TestQgsCircularString::appendZM() { //check dimensionality is inherited from append line if initially empty QgsCircularString cs; - std::unique_ptr toAppend( new QgsCircularString() ); + auto toAppend = std::make_unique(); toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 33, 34 ) << QgsPoint( Qgis::WkbType::PointZM, 41, 42, 43, 44 ) << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 53, 54 ) ); cs.append( toAppend.get() ); diff --git a/tests/src/core/geometry/testqgscurvepolygon.cpp b/tests/src/core/geometry/testqgscurvepolygon.cpp index a0714d5b6bc..15e094fc36f 100644 --- a/tests/src/core/geometry/testqgscurvepolygon.cpp +++ b/tests/src/core/geometry/testqgscurvepolygon.cpp @@ -1189,7 +1189,7 @@ void TestQgsCurvePolygon::testBoundingBoxIntersects() QgsCurvePolygon poly1; QVERIFY( !poly1.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); - std::unique_ptr ext1( new QgsCircularString() ); + auto ext1 = std::make_unique(); ext1->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) << QgsPoint( 0, 18, 3 ) << QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) ); poly1.setExteriorRing( ext1.release() ); @@ -1200,7 +1200,7 @@ void TestQgsCurvePolygon::testBoundingBoxIntersects() QgsCurvePolygon poly2; QVERIFY( !poly2.boundingBoxIntersects( QgsBox3D( 1, 3, 1, 6, 9, 2 ) ) ); - std::unique_ptr ext2( new QgsCircularString() ); + auto ext2 = std::make_unique(); ext2->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) << QgsPoint( 0, 18, 3 ) << QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) ); poly2.setExteriorRing( ext2.release() ); diff --git a/tests/src/core/geometry/testqgsellipse.cpp b/tests/src/core/geometry/testqgsellipse.cpp index db58860b284..8c46e69ab4a 100644 --- a/tests/src/core/geometry/testqgsellipse.cpp +++ b/tests/src/core/geometry/testqgsellipse.cpp @@ -362,7 +362,7 @@ void TestQgsEllipse::toString() void TestQgsEllipse::toLineString() { - std::unique_ptr ls( new QgsLineString() ); + auto ls = std::make_unique(); ls.reset( QgsEllipse( QgsPoint( 0, 0 ), 5, 2, 0 ).toLineString( 2 ) ); QVERIFY( ls->isEmpty() ); // segments too low @@ -379,7 +379,7 @@ void TestQgsEllipse::toLineString() void TestQgsEllipse::toPolygon() { - std::unique_ptr poly( new QgsPolygon() ); + auto poly = std::make_unique(); poly.reset( QgsEllipse( QgsPoint( 0, 0 ), 5, 2, 0 ).toPolygon( 2 ) ); QVERIFY( poly->isEmpty() ); // segments too low diff --git a/tests/src/core/geometry/testqgslinestring.cpp b/tests/src/core/geometry/testqgslinestring.cpp index ade85da7e63..06642f532e1 100644 --- a/tests/src/core/geometry/testqgslinestring.cpp +++ b/tests/src/core/geometry/testqgslinestring.cpp @@ -755,7 +755,7 @@ void TestQgsLineString::gettersSetters() void TestQgsLineString::appendWithZM() { QgsLineString ls; - std::unique_ptr toAppend( new QgsLineString() ); + auto toAppend = std::make_unique(); //check dimensionality is inherited from append line if initially empty toAppend.reset( new QgsLineString() ); @@ -840,7 +840,7 @@ void TestQgsLineString::append() QVERIFY( ls.isEmpty() ); QCOMPARE( ls.numPoints(), 0 ); - std::unique_ptr toAppend( new QgsLineString() ); + auto toAppend = std::make_unique(); toAppend->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); ls.append( toAppend.get() ); @@ -2151,7 +2151,7 @@ void TestQgsLineString::boundingBox() QCOMPARE( ls.boundingBox(), QgsRectangle( -6, -15, -4, -9 ) ); //append - std::unique_ptr toAppend( new QgsLineString() ); + auto toAppend = std::make_unique(); toAppend->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 4, 0 ) ); ls.append( toAppend.get() ); diff --git a/tests/src/core/geometry/testqgsregularpolygon.cpp b/tests/src/core/geometry/testqgsregularpolygon.cpp index 662cc27097d..b68ebd47668 100644 --- a/tests/src/core/geometry/testqgsregularpolygon.cpp +++ b/tests/src/core/geometry/testqgsregularpolygon.cpp @@ -239,7 +239,7 @@ void TestQgsRegularPolygon::conversions() QVERIFY( toP->isEmpty() ); QgsPointSequence ptsPol; - std::unique_ptr pol( new QgsPolygon() ); + auto pol = std::make_unique(); pol.reset( rp.toPolygon() ); QCOMPARE( pol->numInteriorRings(), 0 ); diff --git a/tests/src/core/geometry/testqgstriangle.cpp b/tests/src/core/geometry/testqgstriangle.cpp index 34d950a11d2..03660b0d66a 100644 --- a/tests/src/core/geometry/testqgstriangle.cpp +++ b/tests/src/core/geometry/testqgstriangle.cpp @@ -220,7 +220,7 @@ void TestQgsTriangle::exteriorRing() QVERIFY( !tr.interiorRing( 0 ) ); QCOMPARE( tr.wkbType(), Qgis::WkbType::Triangle ); - std::unique_ptr ext( new QgsLineString() ); + auto ext = std::make_unique(); ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 0, 0 ) ); QVERIFY( ext->isClosed() ); @@ -340,7 +340,7 @@ void TestQgsTriangle::invalidExteriorRing() QgsTriangle tr; // invalid exterior ring - std::unique_ptr ext( new QgsLineString() ); + auto ext = std::make_unique(); ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 5, 10 ) ); tr.setExteriorRing( ext.release() ); @@ -374,7 +374,7 @@ void TestQgsTriangle::invalidNumberOfPoints() { QgsTriangle tr; - std::unique_ptr ext( new QgsLineString() ); + auto ext = std::make_unique(); ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) ); tr.setExteriorRing( ext.release() ); @@ -393,7 +393,7 @@ void TestQgsTriangle::nonClosedRing() QgsTriangle tr; // a non closed exterior ring will be automatically closed - std::unique_ptr ext( new QgsLineString() ); + auto ext = std::make_unique(); ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) ); QVERIFY( !ext->isClosed() ); @@ -418,7 +418,7 @@ void TestQgsTriangle::conversion() { QgsTriangle tr; - std::unique_ptr ext( new QgsLineString() ); + auto ext = std::make_unique(); ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) ); tr.setExteriorRing( ext.release() ); @@ -463,7 +463,7 @@ void TestQgsTriangle::toFromWkt() { QgsTriangle tr; - std::unique_ptr ext( new QgsLineString() ); + auto ext = std::make_unique(); ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) ); tr.setExteriorRing( ext.release() ); @@ -541,7 +541,7 @@ void TestQgsTriangle::toFromWkb() // WKB M // tWKB=QgsTriangle (QgsPoint(0,0, 5), QgsPoint(0, 10, 6), QgsPoint(10, 10, 7)); will produce a TriangleZ - std::unique_ptr ext( new QgsLineString() ); + auto ext = std::make_unique(); ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 6 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 7 ) ); tWKB.setExteriorRing( ext.release() ); @@ -736,7 +736,7 @@ void TestQgsTriangle::deleteVertex() { QgsTriangle tr( QgsPoint( 0, 0 ), QgsPoint( 100, 100 ), QgsPoint( 0, 200 ) ); - std::unique_ptr ring( new QgsLineString() ); + auto ring = std::make_unique(); ring->setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) << QgsPoint( 50, 50 ) << QgsPoint( 0, 25 ) << QgsPoint( 5, 5 ) ); tr.addInteriorRing( ring.release() ); diff --git a/tests/src/core/testqgis.cpp b/tests/src/core/testqgis.cpp index cc08d443974..3ec96f59f2b 100644 --- a/tests/src/core/testqgis.cpp +++ b/tests/src/core/testqgis.cpp @@ -191,7 +191,7 @@ void TestQgis::doubleToString() void TestQgis::signalBlocker() { - std::unique_ptr checkbox( new QCheckBox() ); + auto checkbox = std::make_unique(); QSignalSpy spy( checkbox.get(), &QCheckBox::toggled ); diff --git a/tests/src/core/testqgscallout.cpp b/tests/src/core/testqgscallout.cpp index ebef784b96c..c12eed1dfb5 100644 --- a/tests/src/core/testqgscallout.cpp +++ b/tests/src/core/testqgscallout.cpp @@ -1785,7 +1785,7 @@ void TestQgsCallout::calloutBehindIndividualLabels() void TestQgsCallout::calloutNoDrawToAllParts() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); @@ -1853,7 +1853,7 @@ void TestQgsCallout::calloutNoDrawToAllParts() void TestQgsCallout::calloutDrawToAllParts() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); @@ -1922,7 +1922,7 @@ void TestQgsCallout::calloutDrawToAllParts() void TestQgsCallout::calloutDataDefinedDrawToAllParts() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); @@ -1991,7 +1991,7 @@ void TestQgsCallout::calloutDataDefinedDrawToAllParts() void TestQgsCallout::calloutPointOnExterior() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2054,7 +2054,7 @@ void TestQgsCallout::calloutPointOnExterior() void TestQgsCallout::calloutDataDefinedAnchorPoint() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2117,7 +2117,7 @@ void TestQgsCallout::calloutDataDefinedAnchorPoint() void TestQgsCallout::calloutDataDefinedDestination() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2182,7 +2182,7 @@ void TestQgsCallout::calloutDataDefinedDestination() void TestQgsCallout::calloutDataDefinedOrigin() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2352,7 +2352,7 @@ void TestQgsCallout::manhattanRotated() void TestQgsCallout::manhattanNoDrawToAllParts() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); @@ -2420,7 +2420,7 @@ void TestQgsCallout::manhattanNoDrawToAllParts() void TestQgsCallout::manhattanDrawToAllParts() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); @@ -2489,7 +2489,7 @@ void TestQgsCallout::manhattanDrawToAllParts() void TestQgsCallout::manhattanDataDefinedDrawToAllParts() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); @@ -2558,7 +2558,7 @@ void TestQgsCallout::manhattanDataDefinedDrawToAllParts() void TestQgsCallout::manhattanDataDefinedDestination() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2623,7 +2623,7 @@ void TestQgsCallout::manhattanDataDefinedDestination() void TestQgsCallout::manhattanDataDefinedOrigin() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2688,7 +2688,7 @@ void TestQgsCallout::manhattanDataDefinedOrigin() void TestQgsCallout::curvedAutoLeavingLabelsAtBottomLeft() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2788,7 +2788,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtBottomLeft() void TestQgsCallout::curvedAutoLeavingLabelsAtBottomRight() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2888,7 +2888,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtBottomRight() void TestQgsCallout::curvedAutoLeavingLabelsAtTopLeft() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2988,7 +2988,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtTopLeft() void TestQgsCallout::curvedAutoLeavingLabelsAtTopRight() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3088,7 +3088,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtTopRight() void TestQgsCallout::curvedAutoLeavingLabelsAtTop() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3188,7 +3188,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtTop() void TestQgsCallout::curvedAutoLeavingLabelsAtBottom() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3288,7 +3288,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtBottom() void TestQgsCallout::curvedAutoLeavingLabelsAtLeft() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3388,7 +3388,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtLeft() void TestQgsCallout::curvedAutoLeavingLabelsAtRight() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3488,7 +3488,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtRight() void TestQgsCallout::curvedAutoHorizontalLines() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3557,7 +3557,7 @@ void TestQgsCallout::curvedAutoHorizontalLines() void TestQgsCallout::curvedAutoVerticalLines() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3626,7 +3626,7 @@ void TestQgsCallout::curvedAutoVerticalLines() void TestQgsCallout::curvedClockwise() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3726,7 +3726,7 @@ void TestQgsCallout::curvedClockwise() void TestQgsCallout::curvedCounterClockwise() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3826,7 +3826,7 @@ void TestQgsCallout::curvedCounterClockwise() void TestQgsCallout::curvedCurvature() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; diff --git a/tests/src/core/testqgsdiagram.cpp b/tests/src/core/testqgsdiagram.cpp index 57a5bbf7843..4b94e2f4a3d 100644 --- a/tests/src/core/testqgsdiagram.cpp +++ b/tests/src/core/testqgsdiagram.cpp @@ -1120,7 +1120,7 @@ class TestQgsDiagram : public QgsTest void testClipping() { const QString filename = QStringLiteral( TEST_DATA_DIR ) + "/lines.shp"; - std::unique_ptr vl2( new QgsVectorLayer( filename, QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ) ); + auto vl2 = std::make_unique( filename, QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVariantMap props; props.insert( QStringLiteral( "outline_color" ), QStringLiteral( "#487bb6" ) ); diff --git a/tests/src/core/testqgsexpressioncontext.cpp b/tests/src/core/testqgsexpressioncontext.cpp index 5837c5796c4..18422243f05 100644 --- a/tests/src/core/testqgsexpressioncontext.cpp +++ b/tests/src/core/testqgsexpressioncontext.cpp @@ -841,7 +841,7 @@ void TestQgsExpressionContext::layerScope() layerScope = nullptr; //create a map layer - std::unique_ptr vectorLayer( new QgsVectorLayer( QStringLiteral( "Point?field=col1:integer&field=col2:integer&field=col3:integer" ), QStringLiteral( "test layer" ), QStringLiteral( "memory" ) ) ); + auto vectorLayer = std::make_unique( QStringLiteral( "Point?field=col1:integer&field=col2:integer&field=col3:integer" ), QStringLiteral( "test layer" ), QStringLiteral( "memory" ) ); QgsExpressionContext context; context << QgsExpressionContextUtils::layerScope( vectorLayer.get() ); diff --git a/tests/src/core/testqgsfield.cpp b/tests/src/core/testqgsfield.cpp index 8e5e8f7c9c1..b88ac69bb07 100644 --- a/tests/src/core/testqgsfield.cpp +++ b/tests/src/core/testqgsfield.cpp @@ -81,7 +81,7 @@ void TestQgsField::cleanup() void TestQgsField::create() { - std::unique_ptr field( new QgsField( QStringLiteral( "name" ), QMetaType::Type::Double, QStringLiteral( "double" ), 5, 2, QStringLiteral( "comment" ) ) ); + auto field = std::make_unique( QStringLiteral( "name" ), QMetaType::Type::Double, QStringLiteral( "double" ), 5, 2, QStringLiteral( "comment" ) ); QCOMPARE( field->name(), QString( "name" ) ); QCOMPARE( field->type(), QMetaType::Type::Double ); QCOMPARE( field->typeName(), QString( "double" ) ); diff --git a/tests/src/core/testqgsgdalutils.cpp b/tests/src/core/testqgsgdalutils.cpp index 45a6779ac62..b008214855e 100644 --- a/tests/src/core/testqgsgdalutils.cpp +++ b/tests/src/core/testqgsgdalutils.cpp @@ -154,7 +154,7 @@ void TestQgsGdalUtils::testCreateSingleBandTiffDataset() QVERIFY( QFile::exists( filename ) ); - std::unique_ptr layer( new QgsRasterLayer( filename, "test", "gdal" ) ); + auto layer = std::make_unique( filename, "test", "gdal" ); QVERIFY( layer->isValid() ); QCOMPARE( layer->extent(), QgsRectangle( 1, 1, 21, 11 ) ); QCOMPARE( layer->width(), 40 ); @@ -178,7 +178,7 @@ void TestQgsGdalUtils::testResampleSingleBandRaster() QgsGdalUtils::resampleSingleBandRaster( srcDS.get(), dstDS.get(), GRA_NearestNeighbour, nullptr ); dstDS.reset(); - std::unique_ptr layer( new QgsRasterLayer( outputFilename, "test", "gdal" ) ); + auto layer = std::make_unique( outputFilename, "test", "gdal" ); QVERIFY( layer ); std::unique_ptr block( layer->dataProvider()->block( 1, outputExtent, 2, 2 ) ); QVERIFY( block ); diff --git a/tests/src/core/testqgslabelingengine.cpp b/tests/src/core/testqgslabelingengine.cpp index 6f7b2134e4e..e9341ebb9a1 100644 --- a/tests/src/core/testqgslabelingengine.cpp +++ b/tests/src/core/testqgslabelingengine.cpp @@ -914,7 +914,7 @@ void TestQgsLabelingEngine::testRegisterFeatureUnprojectible() settings.isExpression = true; settings.fitInPolygonOnly = true; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); QgsFeature f( vl2->fields(), 1 ); @@ -957,7 +957,7 @@ void TestQgsLabelingEngine::testRotateHidePartial() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::OverPoint; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); @@ -1033,7 +1033,7 @@ void TestQgsLabelingEngine::testParallelLabelSmallFeature() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::Line; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "linestring?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "linestring?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); @@ -1102,7 +1102,7 @@ void TestQgsLabelingEngine::testAllowDegradedPlacements() // start without degraded placement -- no label should be shown settings.placementSettings().setAllowDegradedPlacement( false ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "linestring?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "linestring?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); @@ -1180,7 +1180,7 @@ void TestQgsLabelingEngine::testOverlapHandling() settings.placement = Qgis::LabelPlacement::OrderedPositionsAroundPoint; settings.priority = 5; - std::unique_ptr vl1( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl1 = std::make_unique( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl1->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0 }, { QStringLiteral( "outline_style" ), QStringLiteral( "no" ) } } ) ) ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl1.get(), QStringLiteral( "test" ), true, &settings ); @@ -1197,7 +1197,7 @@ void TestQgsLabelingEngine::testOverlapHandling() settings.pointSettings().setQuadrant( Qgis::LabelQuadrantPosition::AboveLeft ); settings.priority = 10; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#ff0000" ) }, { QStringLiteral( "outline_width" ), 0 }, { QStringLiteral( "outline_style" ), QStringLiteral( "no" ) } } ) ) ); QgsVectorLayerLabelProvider *provider2 = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); @@ -1343,7 +1343,7 @@ void TestQgsLabelingEngine::testAllowOverlapsIgnoresObstacles() settings.pointSettings().setQuadrant( Qgis::LabelQuadrantPosition::AboveRight ); settings.priority = 2; - std::unique_ptr vl1( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl1 = std::make_unique( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl1->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0 }, { QStringLiteral( "outline_style" ), QStringLiteral( "no" ) } } ) ) ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl1.get(), QStringLiteral( "test" ), true, &settings ); @@ -1360,7 +1360,7 @@ void TestQgsLabelingEngine::testAllowOverlapsIgnoresObstacles() settings.obstacleSettings().setIsObstacle( true ); settings.obstacleSettings().setFactor( 10 ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#ff0000" ) }, { QStringLiteral( "outline_width" ), 0 }, { QStringLiteral( "outline_style" ), QStringLiteral( "no" ) } } ) ) ); QgsVectorLayerLabelProvider *provider2 = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); @@ -1447,7 +1447,7 @@ void TestQgsLabelingEngine::testAdjacentParts() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = true; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1502,7 +1502,7 @@ void TestQgsLabelingEngine::testTouchingParts() // if treated individually, none of these parts are long enough for the label to fit -- but the label should be rendered if the mergeLines setting is true, // because the parts should be merged into a single linestring - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiLineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "MultiLineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -1558,7 +1558,7 @@ void TestQgsLabelingEngine::testMergingLinesWithForks() settings.lineSettings().setMergeLines( true ); // if treated individually, none of these parts are long enough for the label to fit -- but the label should be rendered if the mergeLines setting is true - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -1625,7 +1625,7 @@ void TestQgsLabelingEngine::testMergingLinesWithMinimumSize() settings.thinningSettings().setMinimumFeatureSize( 90.0 ); // if treated individually, none of these parts exceed the minimum feature size set above -- but the label should be rendered if the mergeLines setting is true - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -1688,7 +1688,7 @@ void TestQgsLabelingEngine::testPointLabelTabs() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1742,7 +1742,7 @@ void TestQgsLabelingEngine::testPointLabelTabsHtml() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1795,7 +1795,7 @@ void TestQgsLabelingEngine::testPointLabelHtmlFormatting() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1849,7 +1849,7 @@ void TestQgsLabelingEngine::testPointLabelHtmlFormattingDataDefinedSize() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1902,7 +1902,7 @@ void TestQgsLabelingEngine::testPointLabelHtmlImages() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1959,7 +1959,7 @@ void TestQgsLabelingEngine::testCurvedLabelsHtmlSuperSubscript() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2015,7 +2015,7 @@ void TestQgsLabelingEngine::testCurvedLabelsHtmlWordSpacing() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2072,7 +2072,7 @@ void TestQgsLabelingEngine::testCurvedLabelsTabs() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2129,7 +2129,7 @@ void TestQgsLabelingEngine::testCurvedLabelsTabPositions() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2185,7 +2185,7 @@ void TestQgsLabelingEngine::testCurvedLabelsHtmlFormatting() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2240,7 +2240,7 @@ void TestQgsLabelingEngine::testCurvedPerimeterLabelsHtmlFormatting() settings.maxCurvedCharAngleOut = 45; settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2290,7 +2290,7 @@ void TestQgsLabelingEngine::testCurvedLabelsWithTinySegments() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::Curved; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2349,7 +2349,7 @@ void TestQgsLabelingEngine::testCurvedLabelCorrectLinePlacement() settings.maxCurvedCharAngleIn = 99; settings.maxCurvedCharAngleOut = 99; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2415,7 +2415,7 @@ void TestQgsLabelingEngine::testCurvedLabelNegativeDistance() settings.labelPerPart = false; settings.dist = -5; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2468,7 +2468,7 @@ void TestQgsLabelingEngine::testCurvedLabelOnSmallLineNearCenter() settings.placement = Qgis::LabelPlacement::Curved; settings.labelPerPart = false; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2520,7 +2520,7 @@ void TestQgsLabelingEngine::testCurvedLabelLineOrientationAbove() settings.labelPerPart = false; settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2585,7 +2585,7 @@ void TestQgsLabelingEngine::testCurvedLabelLineOrientationBelow() settings.labelPerPart = false; settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2654,7 +2654,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownAbove() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2722,7 +2722,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownBelow() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2791,7 +2791,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownAbovePositiveOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2859,7 +2859,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownAboveNegativeOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2926,7 +2926,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownLeftPositiveOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -2994,7 +2994,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownLeftNegativeOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3061,7 +3061,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownRightPositiveOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3129,7 +3129,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownRightNegativeOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3195,7 +3195,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintAbove() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3261,7 +3261,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintBelow() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3328,7 +3328,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintAbovePositiveOffse settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3396,7 +3396,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintAboveNegativeOffse settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3463,7 +3463,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintLeftPositiveOffset settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3531,7 +3531,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintLeftNegativeOffset settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3598,7 +3598,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintRightPositiveOffse settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3666,7 +3666,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintRightNegativeOffse settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3730,7 +3730,7 @@ void TestQgsLabelingEngine::testRepeatDistanceWithSmallLine() settings.labelPerPart = false; settings.repeatDistance = 55; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3784,7 +3784,7 @@ void TestQgsLabelingEngine::testParallelPlacementPreferAbove() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::BelowLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.labelPerPart = false; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -3835,7 +3835,7 @@ void TestQgsLabelingEngine::testLabelBoundary() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::OverPoint; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f( vl2->fields(), 1 ); @@ -3904,7 +3904,7 @@ void TestQgsLabelingEngine::testLabelBlockingRegion() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::OverPoint; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f( vl2->fields(), 1 ); @@ -3988,7 +3988,7 @@ void TestQgsLabelingEngine::testLabelRotationWithReprojection() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::OverPoint; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -4094,7 +4094,7 @@ void TestQgsLabelingEngine::drawUnplaced() settings.priority = 3; settings.obstacleSettings().setFactor( 0 ); - std::unique_ptr vl1( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl1 = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl1->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -4114,7 +4114,7 @@ void TestQgsLabelingEngine::drawUnplaced() format.setSize( 90 ); settings.setFormat( format ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -4122,7 +4122,7 @@ void TestQgsLabelingEngine::drawUnplaced() vl2->setLabelsEnabled( true ); // test a label with 0 candidates (line is too short for label) - std::unique_ptr vl3( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl3 = std::make_unique( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl3->setRenderer( new QgsNullSymbolRenderer() ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString(-6.250851540391068 60.6, -6.250851640391068 60.6 )" ) ) ); QVERIFY( vl3->dataProvider()->addFeature( f ) ); @@ -4175,7 +4175,7 @@ void TestQgsLabelingEngine::labelingResults() settings.priority = 10; settings.angleOffset = 3; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -4382,7 +4382,7 @@ void TestQgsLabelingEngine::labelingResultsCurved() settings.placement = Qgis::LabelPlacement::Curved; settings.priority = 10; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -4496,7 +4496,7 @@ void TestQgsLabelingEngine::labelingResultsWithCallouts() settings.callout()->setDataDefinedProperties( calloutProps ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer&field=labelx:double&field=labely:double&field=calloutoriginx:double&field=calloutoriginy:double&field=calloutdestx:double&field=calloutdesty:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=id:integer&field=labelx:double&field=labely:double&field=calloutoriginx:double&field=calloutoriginy:double&field=calloutdestx:double&field=calloutdesty:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 << -20.173 << 58.624 << -11.160 << 58.001 << -3.814 << 56.046 ); @@ -4512,7 +4512,7 @@ void TestQgsLabelingEngine::labelingResultsWithCallouts() vl2->setLabelsEnabled( true ); // another layer - std::unique_ptr vl3( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3857&field=id:integer&field=labelx:double&field=labely:double&field=calloutoriginx:double&field=calloutoriginy:double&field=calloutdestx:double&field=calloutdesty:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl3 = std::make_unique( QStringLiteral( "Point?crs=epsg:3857&field=id:integer&field=labelx:double&field=labely:double&field=calloutoriginx:double&field=calloutoriginy:double&field=calloutdestx:double&field=calloutdesty:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); f.setAttributes( QgsAttributes() << 2 << -3424024 << 7849709 << -2713442 << 7628322 << -2567040 << 6974872 ); f.setGeometry( QgsGeometry::fromPointXY( QgsPointXY( -2995532, 7242679 ) ) ); @@ -4953,7 +4953,7 @@ void TestQgsLabelingEngine::curvedOverrun() settings.labelPerPart = false; settings.lineSettings().setOverrunDistance( 0 ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -5028,7 +5028,7 @@ void TestQgsLabelingEngine::parallelOverrun() settings.labelPerPart = false; settings.lineSettings().setOverrunDistance( 0 ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -5101,7 +5101,7 @@ void TestQgsLabelingEngine::testDataDefinedLabelAllParts() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPolygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "MultiPolygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -5209,7 +5209,7 @@ void TestQgsLabelingEngine::testDataDefinedLabelTabs() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -5506,7 +5506,7 @@ void TestQgsLabelingEngine::testMapUnitLetterSpacing() format.setFont( font ); settings.setFormat( format ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -5560,7 +5560,7 @@ void TestQgsLabelingEngine::testMapUnitWordSpacing() format.setFont( font ); settings.setFormat( format ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -5613,7 +5613,7 @@ void TestQgsLabelingEngine::testLineHeightAbsolute() settings.placement = Qgis::LabelPlacement::Horizontal; settings.setFormat( format ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -5680,7 +5680,7 @@ void TestQgsLabelingEngine::testClipping() settings.placement = Qgis::LabelPlacement::Line; const QString filename = QStringLiteral( TEST_DATA_DIR ) + "/lines.shp"; - std::unique_ptr vl2( new QgsVectorLayer( filename, QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ) ); + auto vl2 = std::make_unique( filename, QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVariantMap props; props.insert( QStringLiteral( "outline_color" ), QStringLiteral( "#487bb6" ) ); @@ -5750,7 +5750,7 @@ void TestQgsLabelingEngine::testLineAnchorParallel() settings.labelPerPart = false; settings.lineSettings().setLineAnchorPercent( 0.0 ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -5814,7 +5814,7 @@ void TestQgsLabelingEngine::testLineAnchorParallelConstraints() settings.lineSettings().setLineAnchorPercent( 0.0 ); settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6012,7 +6012,7 @@ void TestQgsLabelingEngine::testLineAnchorDataDefinedType() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LineAnchorType, QgsProperty::fromExpression( QStringLiteral( "'strict'" ) ) ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6079,7 +6079,7 @@ void TestQgsLabelingEngine::testLineAnchorCurved() settings.lineSettings().setLineAnchorPercent( 0.0 ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6163,7 +6163,7 @@ void TestQgsLabelingEngine::testLineAnchorCurvedConstraints() settings.lineSettings().setLineAnchorPercent( 0.0 ); settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6364,7 +6364,7 @@ void TestQgsLabelingEngine::testLineAnchorCurvedOverrun() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::EndOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6434,7 +6434,7 @@ void TestQgsLabelingEngine::testLineAnchorCurvedStrictAllUpsideDown() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::StartOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6489,7 +6489,7 @@ void TestQgsLabelingEngine::testLineAnchorHorizontal() settings.lineSettings().setLineAnchorPercent( 0.0 ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6554,7 +6554,7 @@ void TestQgsLabelingEngine::testLineAnchorHorizontalConstraints() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6646,7 +6646,7 @@ void TestQgsLabelingEngine::testLineAnchorClipping() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setAnchorClipping( QgsLabelLineSettings::AnchorClipping::UseEntireLine ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#ff0000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6702,7 +6702,7 @@ void TestQgsLabelingEngine::testShowAllLabelsWhenALabelHasNoCandidates() settings.obstacleSettings().setFactor( 10 ); settings.lineSettings().setOverrunDistance( 50 ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:23700&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:23700&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6885,7 +6885,7 @@ void TestQgsLabelingEngine::testLineDirectionSymbolRight() settings.lineSettings().setAddDirectionSymbol( true ); settings.lineSettings().setDirectionSymbolPlacement( QgsLabelLineSettings::DirectionSymbolPlacement::SymbolLeftRight ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6939,7 +6939,7 @@ void TestQgsLabelingEngine::testLineDirectionSymbolLeft() settings.lineSettings().setAddDirectionSymbol( true ); settings.lineSettings().setDirectionSymbolPlacement( QgsLabelLineSettings::DirectionSymbolPlacement::SymbolLeftRight ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -6993,7 +6993,7 @@ void TestQgsLabelingEngine::testLineDirectionSymbolAbove() settings.lineSettings().setAddDirectionSymbol( true ); settings.lineSettings().setDirectionSymbolPlacement( QgsLabelLineSettings::DirectionSymbolPlacement::SymbolAbove ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; @@ -7047,7 +7047,7 @@ void TestQgsLabelingEngine::testLineDirectionSymbolBelow() settings.lineSettings().setAddDirectionSymbol( true ); settings.lineSettings().setDirectionSymbolPlacement( QgsLabelLineSettings::DirectionSymbolPlacement::SymbolBelow ); - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; diff --git a/tests/src/core/testqgslayoutatlas.cpp b/tests/src/core/testqgslayoutatlas.cpp index 9a5a87eeaa1..a9f86672535 100644 --- a/tests/src/core/testqgslayoutatlas.cpp +++ b/tests/src/core/testqgslayoutatlas.cpp @@ -403,7 +403,7 @@ void TestQgsLayoutAtlas::test_remove_layer() void TestQgsLayoutAtlas::context() { - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer&field=labelx:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=id:integer&field=labelx:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsFeature f; QVERIFY( vl2->dataProvider()->addFeature( f ) ); QgsFeature f2; diff --git a/tests/src/core/testqgslayoutitem.cpp b/tests/src/core/testqgslayoutitem.cpp index 0878c5108f6..4a9e7d78d34 100644 --- a/tests/src/core/testqgslayoutitem.cpp +++ b/tests/src/core/testqgslayoutitem.cpp @@ -358,7 +358,7 @@ void TestQgsLayoutItem::positionWithUnits() QgsProject p; QgsLayout l( &p ); - std::unique_ptr item( new TestItem( &l ) ); + auto item = std::make_unique( &l ); item->attemptMove( QgsLayoutPoint( 60.0, 15.0, Qgis::LayoutUnit::Millimeters ) ); QCOMPARE( item->positionWithUnits().x(), 60.0 ); QCOMPARE( item->positionWithUnits().y(), 15.0 ); @@ -690,7 +690,7 @@ void TestQgsLayoutItem::resize() //resize test item (no restrictions), same units as layout l.setUnits( Qgis::LayoutUnit::Millimeters ); - std::unique_ptr item( new TestItem( &l ) ); + auto item = std::make_unique( &l ); const QSignalSpy spySizeChanged( item.get(), &QgsLayoutItem::sizePositionChanged ); item->setRect( 0, 0, 55, 45 ); @@ -760,7 +760,7 @@ void TestQgsLayoutItem::referencePoint() QgsLayout l( &p ); //test setting/getting reference point - std::unique_ptr item( new TestItem( &l ) ); + auto item = std::make_unique( &l ); item->setReferencePoint( QgsLayoutItem::LowerMiddle ); QCOMPARE( item->referencePoint(), QgsLayoutItem::LowerMiddle ); @@ -940,7 +940,7 @@ void TestQgsLayoutItem::adjustPointForReference() QgsProject p; QgsLayout l( &p ); - std::unique_ptr item( new TestItem( &l ) ); + auto item = std::make_unique( &l ); QPointF result = item->adjustPointForReferencePosition( QPointF( 5, 7 ), QSizeF( 2, 4 ), QgsLayoutItem::UpperLeft ); QCOMPARE( result.x(), 5.0 ); QCOMPARE( result.y(), 7.0 ); @@ -1045,7 +1045,7 @@ void TestQgsLayoutItem::fixedSize() QgsLayout l( &p ); l.setUnits( Qgis::LayoutUnit::Millimeters ); - std::unique_ptr item( new FixedSizedItem( &l ) ); + auto item = std::make_unique( &l ); QCOMPARE( item->fixedSize().width(), 2.0 ); QCOMPARE( item->fixedSize().height(), 4.0 ); QCOMPARE( item->fixedSize().units(), Qgis::LayoutUnit::Inches ); @@ -1073,7 +1073,7 @@ void TestQgsLayoutItem::minSize() QgsLayout l( &p ); l.setUnits( Qgis::LayoutUnit::Millimeters ); - std::unique_ptr item( new MinSizedItem( &l ) ); + auto item = std::make_unique( &l ); QCOMPARE( item->minimumSize().width(), 5.0 ); QCOMPARE( item->minimumSize().height(), 10.0 ); QCOMPARE( item->minimumSize().units(), Qgis::LayoutUnit::Centimeters ); @@ -1096,7 +1096,7 @@ void TestQgsLayoutItem::minSize() QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * std::numeric_limits::epsilon() ); //also need check that fixed size trumps min size - std::unique_ptr fixedMinItem( new FixedMinSizedItem( &l ) ); + auto fixedMinItem = std::make_unique( &l ); QCOMPARE( fixedMinItem->minimumSize().width(), 5.0 ); QCOMPARE( fixedMinItem->minimumSize().height(), 9.0 ); QCOMPARE( fixedMinItem->minimumSize().units(), Qgis::LayoutUnit::Centimeters ); @@ -1117,7 +1117,7 @@ void TestQgsLayoutItem::move() //move test item, same units as layout l.setUnits( Qgis::LayoutUnit::Millimeters ); - std::unique_ptr item( new TestItem( &l ) ); + auto item = std::make_unique( &l ); item->setRect( 0, 0, 55, 45 ); item->setPos( 27, 29 ); item->attemptMove( QgsLayoutPoint( 60.0, 15.0, Qgis::LayoutUnit::Millimeters ) ); @@ -1218,7 +1218,7 @@ void TestQgsLayoutItem::setSceneRect() //resize test item (no restrictions), same units as layout l.setUnits( Qgis::LayoutUnit::Millimeters ); - std::unique_ptr item( new TestItem( &l ) ); + auto item = std::make_unique( &l ); const QSignalSpy spySizeChanged( item.get(), &QgsLayoutItem::sizePositionChanged ); item->attemptSetSceneRect( QRectF( 27.0, 29.0, 100, 200 ) ); @@ -1274,7 +1274,7 @@ void TestQgsLayoutItem::page() QCOMPARE( item->pagePositionWithUnits(), QgsLayoutPoint( 5, 5 ) ); // add pages - std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + auto page = std::make_unique( &l ); page->setPageSize( QgsLayoutSize( 500, 100, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); QCOMPARE( item->page(), 0 ); @@ -1570,7 +1570,7 @@ void TestQgsLayoutItem::rotation() QCOMPARE( item->sceneBoundingRect().bottom(), 18.0 ); // set rotation, using top left - std::unique_ptr item2( new TestItem( &l ) ); + auto item2 = std::make_unique( &l ); item2->attemptMove( QgsLayoutPoint( 5.0, 8.0 ) ); item2->attemptResize( QgsLayoutSize( 10.0, 6.0 ) ); item2->setItemRotation( 90, false ); @@ -2061,12 +2061,12 @@ void TestQgsLayoutItem::excludeFromExports() QgsProject proj; QgsLayout l( &proj ); - std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + auto page = std::make_unique( &l ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr fillSymbol( new QgsFillSymbol() ); + auto fillSymbol = std::make_unique(); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( Qt::transparent ); simpleFill->setStrokeColor( Qt::transparent ); diff --git a/tests/src/core/testqgslayoutpage.cpp b/tests/src/core/testqgslayoutpage.cpp index 5b17ee30699..a09835be975 100644 --- a/tests/src/core/testqgslayoutpage.cpp +++ b/tests/src/core/testqgslayoutpage.cpp @@ -63,7 +63,7 @@ void TestQgsLayoutPage::itemType() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + auto page = std::make_unique( &l ); QCOMPARE( page->type(), static_cast( QgsLayoutItemRegistry::LayoutPage ) ); } @@ -71,7 +71,7 @@ void TestQgsLayoutPage::pageSize() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + auto page = std::make_unique( &l ); page->setPageSize( QgsLayoutSize( 270, 297, Qgis::LayoutUnit::Meters ) ); QCOMPARE( page->pageSize().width(), 270.0 ); QCOMPARE( page->pageSize().height(), 297.0 ); @@ -120,7 +120,7 @@ void TestQgsLayoutPage::grid() // test that grid follows page around QgsProject p; QgsLayout l( &p ); - std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + auto page = std::make_unique( &l ); // should have a grid QVERIFY( page->mGrid.get() ); @@ -151,7 +151,7 @@ void TestQgsLayoutPage::defaultPaper() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + auto page = std::make_unique( &l ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); @@ -162,12 +162,12 @@ void TestQgsLayoutPage::transparentPaper() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + auto page = std::make_unique( &l ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr fillSymbol( new QgsFillSymbol() ); + auto fillSymbol = std::make_unique(); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( Qt::transparent ); simpleFill->setStrokeColor( Qt::transparent ); @@ -180,7 +180,7 @@ void TestQgsLayoutPage::borderedPaper() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + auto page = std::make_unique( &l ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); @@ -199,7 +199,7 @@ void TestQgsLayoutPage::markerLinePaper() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + auto page = std::make_unique( &l ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); @@ -216,7 +216,7 @@ void TestQgsLayoutPage::hiddenPages() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + auto page = std::make_unique( &l ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); @@ -236,7 +236,7 @@ void TestQgsLayoutPage::pageLayout() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr page1( new QgsLayoutItemPage( &l ) ); + auto page1 = std::make_unique( &l ); page1->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); const QPageLayout layout1 = page1->pageLayout(); @@ -246,7 +246,7 @@ void TestQgsLayoutPage::pageLayout() QCOMPARE( layout1.pageSize().size( QPageSize::Millimeter ).width(), 210 ); QCOMPARE( layout1.pageSize().size( QPageSize::Millimeter ).height(), 297 ); - std::unique_ptr page2( new QgsLayoutItemPage( &l ) ); + auto page2 = std::make_unique( &l ); page2->setPageSize( QgsLayoutSize( 210, 297, Qgis::LayoutUnit::Millimeters ) ); const QPageLayout layout2 = page2->pageLayout(); diff --git a/tests/src/core/testqgslayoutpicture.cpp b/tests/src/core/testqgslayoutpicture.cpp index e94975438e6..6a1efa0427f 100644 --- a/tests/src/core/testqgslayoutpicture.cpp +++ b/tests/src/core/testqgslayoutpicture.cpp @@ -169,7 +169,7 @@ void TestQgsLayoutPicture::pictureRotation() mPicture->setPictureRotation( 0 ); // Set picture rotation on uninitialized picture should not create an invalid size (NaN) - std::unique_ptr uninitialized( new QgsLayoutItemPicture( mLayout ) ); + auto uninitialized = std::make_unique( mLayout ); uninitialized->setResizeMode( QgsLayoutItemPicture::ZoomResizeFrame ); QCOMPARE( uninitialized->sizeWithUnits().toQSizeF(), QSizeF( 0, 0 ) ); uninitialized->setPictureRotation( 10 ); diff --git a/tests/src/core/testqgslayoutshapes.cpp b/tests/src/core/testqgslayoutshapes.cpp index 35ec1e6e004..ca539a201ab 100644 --- a/tests/src/core/testqgslayoutshapes.cpp +++ b/tests/src/core/testqgslayoutshapes.cpp @@ -72,7 +72,7 @@ void TestQgsLayoutShapes::rectangle() shape->attemptResize( QgsLayoutSize( 150, 100 ) ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr fillSymbol( new QgsFillSymbol() ); + auto fillSymbol = std::make_unique(); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( QColor( 255, 150, 0 ) ); simpleFill->setStrokeColor( QColor( 0, 0, 0 ) ); @@ -97,7 +97,7 @@ void TestQgsLayoutShapes::triangle() shape->attemptResize( QgsLayoutSize( 150, 100 ) ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr fillSymbol( new QgsFillSymbol() ); + auto fillSymbol = std::make_unique(); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( QColor( 255, 150, 0 ) ); simpleFill->setStrokeColor( QColor( 0, 0, 0 ) ); @@ -122,7 +122,7 @@ void TestQgsLayoutShapes::ellipse() shape->attemptResize( QgsLayoutSize( 150, 100 ) ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr fillSymbol( new QgsFillSymbol() ); + auto fillSymbol = std::make_unique(); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( QColor( 255, 150, 0 ) ); simpleFill->setStrokeColor( QColor( 0, 0, 0 ) ); @@ -146,7 +146,7 @@ void TestQgsLayoutShapes::roundedRectangle() shape->attemptResize( QgsLayoutSize( 150, 100 ) ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr fillSymbol( new QgsFillSymbol() ); + auto fillSymbol = std::make_unique(); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( QColor( 255, 150, 0 ) ); simpleFill->setStrokeColor( QColor( 0, 0, 0 ) ); diff --git a/tests/src/core/testqgslegendrenderer.cpp b/tests/src/core/testqgslegendrenderer.cpp index be637721712..5e0310ff4ea 100644 --- a/tests/src/core/testqgslegendrenderer.cpp +++ b/tests/src/core/testqgslegendrenderer.cpp @@ -307,7 +307,7 @@ void TestQgsLegendRenderer::init() mRL = new QgsRasterLayer( QString( tempFileName ), QStringLiteral( "Raster Layer" ), QStringLiteral( "gdal" ) ); - std::unique_ptr rasterRenderer( new TestRasterRenderer( mRL->dataProvider(), 1, { QgsPalettedRasterRenderer::Class( 1, QColor( 0, 0, 0 ), QStringLiteral( "1" ) ), QgsPalettedRasterRenderer::Class( 2, QColor( 255, 255, 255 ), QStringLiteral( "2" ) ) } ) ); + auto rasterRenderer = std::make_unique( mRL->dataProvider(), 1, QgsPalettedRasterRenderer::ClassData { QgsPalettedRasterRenderer::Class( 1, QColor( 0, 0, 0 ), QStringLiteral( "1" ) ), QgsPalettedRasterRenderer::Class( 2, QColor( 255, 255, 255 ), QStringLiteral( "2" ) ) } ); mRL->setRenderer( rasterRenderer.release() ); QgsProject::instance()->addMapLayer( mRL ); @@ -912,7 +912,7 @@ void TestQgsLegendRenderer::testMapUnits() sym->setSizeUnit( Qgis::RenderUnit::Millimeters ); catRenderer->updateCategorySymbol( 2, sym ); - std::unique_ptr root( new QgsLayerTree() ); + auto root = std::make_unique(); root->addLayer( mVL3 ); QgsLayerTreeModel legendModel( root.get() ); @@ -1074,7 +1074,7 @@ void TestQgsLegendRenderer::testFilterByMapSameSymbol() const QString testName = QStringLiteral( "legend_filter_by_map_dupe" ); - std::unique_ptr root( new QgsLayerTree() ); + auto root = std::make_unique(); root->addLayer( vl4 ); QgsLayerTreeModel legendModel( root.get() ); @@ -1101,7 +1101,7 @@ bool TestQgsLegendRenderer::_testLegendColumns( int itemCount, int columnCount, QgsFillSymbol *sym = new QgsFillSymbol(); sym->setColor( Qt::cyan ); - std::unique_ptr root( new QgsLayerTree() ); + auto root = std::make_unique(); QList layers; for ( int i = 1; i <= itemCount; ++i ) @@ -1305,7 +1305,7 @@ void TestQgsLegendRenderer::testRasterStroke() { const QString testName = QStringLiteral( "legend_raster_border" ); - std::unique_ptr root( new QgsLayerTree() ); + auto root = std::make_unique(); root->addLayer( mRL ); QgsLayerTreeModel legendModel( root.get() ); @@ -1480,7 +1480,7 @@ void TestQgsLegendRenderer::testDiagramAttributeLegend() dls.setShowAllDiagrams( true ); vl4->setDiagramLayerSettings( dls ); - std::unique_ptr root( new QgsLayerTree() ); + auto root = std::make_unique(); root->addLayer( vl4 ); QgsLayerTreeModel legendModel( root.get() ); @@ -1598,7 +1598,7 @@ void TestQgsLegendRenderer::testDiagramSizeLegend() dls.setShowAllDiagrams( true ); vl4->setDiagramLayerSettings( dls ); - std::unique_ptr root( new QgsLayerTree() ); + auto root = std::make_unique(); root->addLayer( vl4 ); QgsLayerTreeModel legendModel( root.get() ); @@ -1925,7 +1925,7 @@ void TestQgsLegendRenderer::testColumnsMixedSymbolSize() QgsMarkerSymbol *sym = new QgsMarkerSymbol(); sym->setColor( Qt::cyan ); - std::unique_ptr root( new QgsLayerTree() ); + auto root = std::make_unique(); QList layers; for ( double size : { 4, 5, 16 } ) @@ -2140,7 +2140,7 @@ void TestQgsLegendRenderer::testLabelLegend() void TestQgsLegendRenderer::testHeatmap() { - std::unique_ptr root( new QgsLayerTree() ); + auto root = std::make_unique(); QgsVectorLayer *vl = new QgsVectorLayer( QStringLiteral( "Points" ), QStringLiteral( "Points" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( vl ); diff --git a/tests/src/core/testqgsmaprendererjob.cpp b/tests/src/core/testqgsmaprendererjob.cpp index 7bc0bcd48fa..0ccd5f8416b 100644 --- a/tests/src/core/testqgsmaprendererjob.cpp +++ b/tests/src/core/testqgsmaprendererjob.cpp @@ -1098,7 +1098,7 @@ void TestQgsMapRendererJob::testMapShading() shadingRenderer.setActiveHillshading( true ); shadingRenderer.setActiveEyeDomeLighting( false ); mapSettings.setElevationShadingRenderer( shadingRenderer ); - std::unique_ptr renderJob( new QgsMapRendererSequentialJob( mapSettings ) ); + auto renderJob = std::make_unique( mapSettings ); renderJob->start(); renderJob->waitForFinished(); QImage img = renderJob->renderedImage(); diff --git a/tests/src/core/testqgsmapsettingsutils.cpp b/tests/src/core/testqgsmapsettingsutils.cpp index dd6a59198d9..6df44a86310 100644 --- a/tests/src/core/testqgsmapsettingsutils.cpp +++ b/tests/src/core/testqgsmapsettingsutils.cpp @@ -80,7 +80,7 @@ void TestQgsMapSettingsUtils::containsAdvancedEffects() { QgsMapSettings mapSettings = mMapSettings; - std::unique_ptr layer( new QgsVectorLayer( QStringLiteral( "Point?field=col1:real" ), QStringLiteral( "layer" ), QStringLiteral( "memory" ) ) ); + auto layer = std::make_unique( QStringLiteral( "Point?field=col1:real" ), QStringLiteral( "layer" ), QStringLiteral( "memory" ) ); layer->setBlendMode( QPainter::CompositionMode_Multiply ); QList layers; diff --git a/tests/src/core/testqgsmeshlayer.cpp b/tests/src/core/testqgsmeshlayer.cpp index 65afef7e4d1..bc759e8c97d 100644 --- a/tests/src/core/testqgsmeshlayer.cpp +++ b/tests/src/core/testqgsmeshlayer.cpp @@ -1473,7 +1473,7 @@ void TestQgsMeshLayer::test_dataset_group_item_tree_item() const QgsReadWriteContext context; const QDomElement rootElement = rootItem->writeXml( doc, context ); - std::unique_ptr otherRoot( new QgsMeshDatasetGroupTreeItem( rootElement, context ) ); + auto otherRoot = std::make_unique( rootElement, context ); for ( int i = 0; i < rootItem->totalChildCount(); ++i ) QCOMPARE( otherRoot->childFromDatasetGroupIndex( i )->name(), names.at( i ) ); diff --git a/tests/src/core/testqgspainteffect.cpp b/tests/src/core/testqgspainteffect.cpp index 723cb5334c6..f8b302e2370 100644 --- a/tests/src/core/testqgspainteffect.cpp +++ b/tests/src/core/testqgspainteffect.cpp @@ -649,7 +649,7 @@ void TestQgsPaintEffect::glow() void TestQgsPaintEffect::transform() { //create - std::unique_ptr effect( new QgsTransformEffect() ); + auto effect = std::make_unique(); QVERIFY( effect.get() ); effect->setEnabled( false ); QCOMPARE( effect->enabled(), false ); @@ -680,7 +680,7 @@ void TestQgsPaintEffect::transform() QCOMPARE( effect->drawMode(), QgsPaintEffect::Modifier ); //copy constructor - std::unique_ptr copy( new QgsTransformEffect( *effect ) ); + auto copy = std::make_unique( *effect ); QVERIFY( copy.get() ); QCOMPARE( copy->enabled(), false ); QCOMPARE( copy->translateX(), 6.0 ); diff --git a/tests/src/core/testqgspallabeling.cpp b/tests/src/core/testqgspallabeling.cpp index aa32a16ab1a..49daa8a9e7c 100644 --- a/tests/src/core/testqgspallabeling.cpp +++ b/tests/src/core/testqgspallabeling.cpp @@ -209,7 +209,7 @@ void TestQgsPalLabeling::testGeometryGenerator() settings.geometryGeneratorType = Qgis::GeometryType::Point; settings.geometryGenerator = "translate($geometry, 1, 0)"; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); @@ -280,7 +280,7 @@ void TestQgsPalLabeling::testPolygonWithEmptyRing() settings.placement = Qgis::LabelPlacement::OverPoint; - std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + auto vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); diff --git a/tests/src/core/testqgspointlocator.cpp b/tests/src/core/testqgspointlocator.cpp index 9c2fa9d354d..6e2f1859fff 100644 --- a/tests/src/core/testqgspointlocator.cpp +++ b/tests/src/core/testqgspointlocator.cpp @@ -515,7 +515,7 @@ class TestQgsPointLocator : public QObject void testInterpolatedPoint() { - std::unique_ptr curveLayer( new QgsVectorLayer( QStringLiteral( "CircularStringZ" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ) ); + auto curveLayer = std::make_unique( QStringLiteral( "CircularStringZ" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); QgsFeature f1; const QgsGeometry f1g = QgsGeometry::fromWkt( "CircularStringZ (0 0 0, 5 5 5, 0 10 10)" ); f1.setGeometry( f1g ); @@ -539,7 +539,7 @@ class TestQgsPointLocator : public QObject QCOMPARE( pt2, QgsPointXY( 0, 10 ) ); QCOMPARE( m1.interpolatedPoint( QgsCoordinateReferenceSystem() ), QgsPoint( 3.53553390593273775, 8.53553390593273775, 7.70598050073098584 ) ); - std::unique_ptr lineLayer( new QgsVectorLayer( QStringLiteral( "LineStringZ" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ) ); + auto lineLayer = std::make_unique( QStringLiteral( "LineStringZ" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); QgsFeature f2; const QgsGeometry f2g = QgsGeometry::fromWkt( "LineStringZ (0 0 0, 5 5 5, 0 10 10)" ); f2.setGeometry( f2g ); diff --git a/tests/src/core/testqgsrasterfilewriter.cpp b/tests/src/core/testqgsrasterfilewriter.cpp index 73b1308512a..855424f20eb 100644 --- a/tests/src/core/testqgsrasterfilewriter.cpp +++ b/tests/src/core/testqgsrasterfilewriter.cpp @@ -114,7 +114,7 @@ bool TestQgsRasterFileWriter::writeTest( const QString &rasterName ) return false; } - std::unique_ptr mpRasterLayer( new QgsRasterLayer( copiedSrc, rasterFileInfo.completeBaseName() ) ); + auto mpRasterLayer = std::make_unique( copiedSrc, rasterFileInfo.completeBaseName() ); if ( !mpRasterLayer->isValid() ) return false; diff --git a/tests/src/core/testqgssnappingutils.cpp b/tests/src/core/testqgssnappingutils.cpp index 00c8c731eee..86d4c8baa50 100644 --- a/tests/src/core/testqgssnappingutils.cpp +++ b/tests/src/core/testqgssnappingutils.cpp @@ -319,7 +319,7 @@ class TestQgsSnappingUtils : public QObject void testSnapOnIntersectionCurveZ() { // testing with a layer with curve and Z - std::unique_ptr vCurveZ( new QgsVectorLayer( QStringLiteral( "CircularStringZ" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ) ); + auto vCurveZ = std::make_unique( QStringLiteral( "CircularStringZ" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsFeature f1; const QgsGeometry f1g = QgsGeometry::fromWkt( "CircularStringZ (0 0 0, 5 5 5, 0 10 10)" ); f1.setGeometry( f1g ); @@ -362,7 +362,7 @@ class TestQgsSnappingUtils : public QObject } void testSnapOnIntersectionMultiGeom() { - std::unique_ptr vMulti( new QgsVectorLayer( QStringLiteral( "MultiLineStringZ" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ) ); + auto vMulti = std::make_unique( QStringLiteral( "MultiLineStringZ" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ); QgsFeature f1; const QgsGeometry f1g = QgsGeometry::fromWkt( "MultiLineStringZ ((0 0 0, 0 5 5), (5 0 10, 5 5 10))" ); f1.setGeometry( f1g ); @@ -403,7 +403,7 @@ class TestQgsSnappingUtils : public QObject } void testSnapOnCentroidAndMiddleSegment() { - std::unique_ptr vSnapCentroidMiddle( new QgsVectorLayer( QStringLiteral( "LineString" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ) ); + auto vSnapCentroidMiddle = std::make_unique( QStringLiteral( "LineString" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ); QgsFeature f1; const QgsGeometry f1g = QgsGeometry::fromWkt( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ); f1.setGeometry( f1g ); @@ -440,7 +440,7 @@ class TestQgsSnappingUtils : public QObject void testSnapOnLineEndpoints() { - std::unique_ptr vSnapCentroidMiddle( new QgsVectorLayer( QStringLiteral( "LineString" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ) ); + auto vSnapCentroidMiddle = std::make_unique( QStringLiteral( "LineString" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ); QgsFeature f1; const QgsGeometry f1g = QgsGeometry::fromWkt( "LineString (0 0, 0 5, 5 5, 5 0)" ); f1.setGeometry( f1g ); @@ -489,7 +489,7 @@ class TestQgsSnappingUtils : public QObject void testSnapOnLineEndpointsMultiLine() { - std::unique_ptr vSnapCentroidMiddle( new QgsVectorLayer( QStringLiteral( "MultiLineString" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ) ); + auto vSnapCentroidMiddle = std::make_unique( QStringLiteral( "MultiLineString" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ); QgsFeature f1; const QgsGeometry f1g = QgsGeometry::fromWkt( "MultiLineString ((0 0, 0 5, 5 5, 5 0), (0 -0.1, 0 -5, 5 -0.5))" ); f1.setGeometry( f1g ); @@ -557,7 +557,7 @@ class TestQgsSnappingUtils : public QObject void testSnapOnPolygonEndpoints() { - std::unique_ptr vSnapCentroidMiddle( new QgsVectorLayer( QStringLiteral( "Polygon" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ) ); + auto vSnapCentroidMiddle = std::make_unique( QStringLiteral( "Polygon" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ); QgsFeature f1; const QgsGeometry f1g = QgsGeometry::fromWkt( "Polygon ((1 0, 0 5, 5 5, 5 0, 1 0),(3 2, 3.5 2, 3.5 3, 3 2))" ); f1.setGeometry( f1g ); @@ -608,7 +608,7 @@ class TestQgsSnappingUtils : public QObject void testSnapOnMultiPolygonEndpoints() { - std::unique_ptr vSnapCentroidMiddle( new QgsVectorLayer( QStringLiteral( "MultiPolygon" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ) ); + auto vSnapCentroidMiddle = std::make_unique( QStringLiteral( "MultiPolygon" ), QStringLiteral( "m" ), QStringLiteral( "memory" ) ); QgsFeature f1; const QgsGeometry f1g = QgsGeometry::fromWkt( "MultiPolygon (((1 0, 0 5, 5 5, 5 0, 1 0),(3 2, 3.5 2, 3.5 3, 3 2)), ((10 0, 10 5, 15 5, 15 0, 10 0),(13 2, 13.5 2, 13.5 3, 13 2)) )" ); f1.setGeometry( f1g ); diff --git a/tests/src/core/testqgsspatialindexkdbush.cpp b/tests/src/core/testqgsspatialindexkdbush.cpp index 0a780a52899..8c69f7041cb 100644 --- a/tests/src/core/testqgsspatialindexkdbush.cpp +++ b/tests/src/core/testqgsspatialindexkdbush.cpp @@ -119,10 +119,10 @@ class TestQgsSpatialIndexKdBush : public QObject for ( QgsFeature f : _pointFeatures() ) vl->dataProvider()->addFeature( f ); - std::unique_ptr index( new QgsSpatialIndexKDBush( *vl->dataProvider() ) ); + auto index = std::make_unique( *vl->dataProvider() ); // create copy of the index - std::unique_ptr indexCopy( new QgsSpatialIndexKDBush( *index ) ); + auto indexCopy = std::make_unique( *index ); QVERIFY( index->d == indexCopy->d ); QVERIFY( index->d->ref == 2 ); diff --git a/tests/src/core/testqgsstyle.cpp b/tests/src/core/testqgsstyle.cpp index a1fbde844d6..2c4569c6e6a 100644 --- a/tests/src/core/testqgsstyle.cpp +++ b/tests/src/core/testqgsstyle.cpp @@ -1581,7 +1581,7 @@ void TestStyle::testColorRampShaderClassificationEqualInterval() { // Test Type::Interpolated and ClassificationMode::EqualInterval { - std::unique_ptr shader( new QgsColorRampShader( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Linear, Qgis::ShaderClassificationMethod::EqualInterval ) ); + auto shader = std::make_unique( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Linear, Qgis::ShaderClassificationMethod::EqualInterval ); shader->classifyColorRamp( 5, -1 ); QList itemsList = shader->colorRampItemList(); @@ -1597,7 +1597,7 @@ void TestStyle::testColorRampShaderClassificationEqualInterval() // Test Type::Exact and ClassificationMode::EqualInterval { - std::unique_ptr shader( new QgsColorRampShader( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Exact, Qgis::ShaderClassificationMethod::EqualInterval ) ); + auto shader = std::make_unique( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Exact, Qgis::ShaderClassificationMethod::EqualInterval ); shader->classifyColorRamp( 5, -1 ); QList itemsList = shader->colorRampItemList(); @@ -1613,7 +1613,7 @@ void TestStyle::testColorRampShaderClassificationEqualInterval() // Test Type::Discrete and ClassificationMode::EqualInterval { - std::unique_ptr shader( new QgsColorRampShader( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Discrete, Qgis::ShaderClassificationMethod::EqualInterval ) ); + auto shader = std::make_unique( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Discrete, Qgis::ShaderClassificationMethod::EqualInterval ); shader->classifyColorRamp( 5, -1 ); QList itemsList = shader->colorRampItemList(); @@ -1631,7 +1631,7 @@ void TestStyle::testColorRampShaderClassificationEqualInterval() for ( int i = 0; i < 3; ++i ) { const Qgis::ShaderInterpolationMethod type = static_cast( i ); - std::unique_ptr shader( new QgsColorRampShader( 0.0, 0.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), type, Qgis::ShaderClassificationMethod::EqualInterval ) ); + auto shader = std::make_unique( 0.0, 0.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), type, Qgis::ShaderClassificationMethod::EqualInterval ); shader->classifyColorRamp( 5, -1 ); QList itemsList = shader->colorRampItemList(); @@ -1648,7 +1648,7 @@ void TestStyle::testColorRampShaderClassificationContinius() { // Test Type::Interpolated and ClassificationMode::Continuous { - std::unique_ptr shader( new QgsColorRampShader( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Linear, Qgis::ShaderClassificationMethod::Continuous ) ); + auto shader = std::make_unique( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Linear, Qgis::ShaderClassificationMethod::Continuous ); shader->classifyColorRamp( 5, -1 ); QList itemsList = shader->colorRampItemList(); @@ -1661,7 +1661,7 @@ void TestStyle::testColorRampShaderClassificationContinius() // Test Type::Exact and ClassificationMode::Continuous { - std::unique_ptr shader( new QgsColorRampShader( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Exact, Qgis::ShaderClassificationMethod::Continuous ) ); + auto shader = std::make_unique( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Exact, Qgis::ShaderClassificationMethod::Continuous ); shader->classifyColorRamp( 5, -1 ); QList itemsList = shader->colorRampItemList(); @@ -1674,7 +1674,7 @@ void TestStyle::testColorRampShaderClassificationContinius() // Test Type::Discrete and ClassificationMode::Continuous { - std::unique_ptr shader( new QgsColorRampShader( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Discrete, Qgis::ShaderClassificationMethod::Continuous ) ); + auto shader = std::make_unique( 0.0, 255.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), Qgis::ShaderInterpolationMethod::Discrete, Qgis::ShaderClassificationMethod::Continuous ); shader->classifyColorRamp( 5, -1 ); QList itemsList = shader->colorRampItemList(); @@ -1689,7 +1689,7 @@ void TestStyle::testColorRampShaderClassificationContinius() for ( int i = 0; i < 3; ++i ) { const Qgis::ShaderInterpolationMethod type = static_cast( i ); - std::unique_ptr shader( new QgsColorRampShader( 0.0, 0.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), type, Qgis::ShaderClassificationMethod::Continuous ) ); + auto shader = std::make_unique( 0.0, 0.0, new QgsGradientColorRamp( Qt::green, Qt::blue ), type, Qgis::ShaderClassificationMethod::Continuous ); shader->classifyColorRamp( 5, -1 ); QList itemsList = shader->colorRampItemList(); diff --git a/tests/src/core/testqgstaskmanager.cpp b/tests/src/core/testqgstaskmanager.cpp index 67862e78fd8..d426f848056 100644 --- a/tests/src/core/testqgstaskmanager.cpp +++ b/tests/src/core/testqgstaskmanager.cpp @@ -376,7 +376,7 @@ void TestQgsTaskManager::cleanup() void TestQgsTaskManager::task() { - std::unique_ptr task( new TestTask( QStringLiteral( "test_task_desc" ) ) ); + auto task = std::make_unique( QStringLiteral( "test_task_desc" ) ); QCOMPARE( task->status(), QgsTask::Queued ); QCOMPARE( task->description(), QStringLiteral( "test_task_desc" ) ); QVERIFY( !task->isActive() ); @@ -394,7 +394,7 @@ void TestQgsTaskManager::task() QCOMPARE( static_cast( statusSpy.at( 1 ).at( 0 ).toInt() ), QgsTask::Complete ); //test that calling stopped sets correct state - std::unique_ptr failTask( new FailTask( QStringLiteral( "task_fail" ) ) ); + auto failTask = std::make_unique( QStringLiteral( "task_fail" ) ); QSignalSpy stoppedSpy( failTask.get(), &QgsTask::taskTerminated ); QSignalSpy statusSpy2( failTask.get(), &QgsTask::statusChanged ); failTask->start(); diff --git a/tests/src/gui/testqgsdualview.cpp b/tests/src/gui/testqgsdualview.cpp index be8dbb739a7..fc399c455a9 100644 --- a/tests/src/gui/testqgsdualview.cpp +++ b/tests/src/gui/testqgsdualview.cpp @@ -322,7 +322,7 @@ void TestQgsDualView::testAttributeFormSharedValueScanning() void TestQgsDualView::testNoGeom() { //test that both the master model and cache for the dual view either both request geom or both don't request geom - std::unique_ptr dv( new QgsDualView() ); + auto dv = std::make_unique(); // request with geometry QgsFeatureRequest req; diff --git a/tests/src/gui/testqgsexternalstoragefilewidget.cpp b/tests/src/gui/testqgsexternalstoragefilewidget.cpp index 9bd532c51ca..bc32c3e695d 100644 --- a/tests/src/gui/testqgsexternalstoragefilewidget.cpp +++ b/tests/src/gui/testqgsexternalstoragefilewidget.cpp @@ -815,7 +815,7 @@ void TestQgsExternalStorageFileWidget::testDragAndDrop() QgsExternalStorageFileWidget w; w.show(); - std::unique_ptr mime( new QMimeData() ); + auto mime = std::make_unique(); mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) ); QIcon editIcon = QgsApplication::getThemeIcon( QStringLiteral( "/mActionToggleEditing.svg" ) ); @@ -843,11 +843,11 @@ void TestQgsExternalStorageFileWidget::testDragAndDrop() QVERIFY( !w.mCancelButton->isVisible() ); QVERIFY( w.acceptDrops() ); - std::unique_ptr dragEvent( new QDragEnterEvent( QPoint( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + auto dragEvent = std::make_unique( QPoint( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ); w.dragEnterEvent( dragEvent.get() ); QVERIFY( dragEvent->isAccepted() ); - std::unique_ptr dropEvent( new QDropEvent( QPoint( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + auto dropEvent = std::make_unique( QPoint( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ); w.dropEvent( dropEvent.get() ); QVERIFY( dropEvent->isAccepted() ); diff --git a/tests/src/gui/testqgsfeaturelistcombobox.cpp b/tests/src/gui/testqgsfeaturelistcombobox.cpp index fc6ee9ab107..45e4b019bf7 100644 --- a/tests/src/gui/testqgsfeaturelistcombobox.cpp +++ b/tests/src/gui/testqgsfeaturelistcombobox.cpp @@ -125,7 +125,7 @@ void TestQgsFeatureListComboBox::cleanup() void TestQgsFeatureListComboBox::testSetGetLayer() { - std::unique_ptr cb( new QgsFeatureListComboBox() ); + auto cb = std::make_unique(); QVERIFY( cb->sourceLayer() == nullptr ); cb->setSourceLayer( mLayer.get() ); @@ -156,7 +156,7 @@ void TestQgsFeatureListComboBox::testSetGetForeignKey() void TestQgsFeatureListComboBox::testMultipleForeignKeys() { - std::unique_ptr cb( new QgsFeatureListComboBox() ); + auto cb = std::make_unique(); QgsApplication::setNullRepresentation( QStringLiteral( "nope" ) ); @@ -213,7 +213,7 @@ void TestQgsFeatureListComboBox::testValuesAndSelection() QFETCH( bool, allowNull ); QgsApplication::setNullRepresentation( QStringLiteral( "nope" ) ); - std::unique_ptr cb( new QgsFeatureListComboBox() ); + auto cb = std::make_unique(); QSignalSpy spy( cb.get(), &QgsFeatureListComboBox::identifierValueChanged ); @@ -251,7 +251,7 @@ void TestQgsFeatureListComboBox::testValuesAndSelection() void TestQgsFeatureListComboBox::nullRepresentation() { QgsApplication::setNullRepresentation( QStringLiteral( "nope" ) ); - std::unique_ptr cb( new QgsFeatureListComboBox() ); + auto cb = std::make_unique(); QgsFeatureFilterModel *model = qobject_cast( cb->model() ); QEventLoop loop; @@ -271,7 +271,7 @@ void TestQgsFeatureListComboBox::testNotExistingYetFeature() // test behavior when feature list combo box identifier values references a // not existing yet feature (created but not saved for instance) - std::unique_ptr cb( new QgsFeatureListComboBox() ); + auto cb = std::make_unique(); QgsFeatureFilterModel *model = qobject_cast( cb->model() ); QEventLoop loop; connect( model, &QgsFeatureFilterModel::filterJobCompleted, &loop, &QEventLoop::quit ); @@ -293,7 +293,7 @@ void TestQgsFeatureListComboBox::testFeatureFurtherThanFetchLimit() { const int fetchLimit = 20; QVERIFY( fetchLimit < mLayer->featureCount() ); - std::unique_ptr cb( new QgsFeatureListComboBox() ); + auto cb = std::make_unique(); QgsFeatureFilterModel *model = qobject_cast( cb->model() ); QSignalSpy spy( cb.get(), &QgsFeatureListComboBox::identifierValueChanged ); model->setFetchLimit( 20 ); diff --git a/tests/src/gui/testqgsfieldexpressionwidget.cpp b/tests/src/gui/testqgsfieldexpressionwidget.cpp index 054d57c6976..6c2b229e8b0 100644 --- a/tests/src/gui/testqgsfieldexpressionwidget.cpp +++ b/tests/src/gui/testqgsfieldexpressionwidget.cpp @@ -139,7 +139,7 @@ void TestQgsFieldExpressionWidget::asExpression() layer->updateFields(); QgsProject::instance()->addMapLayer( layer ); - std::unique_ptr widget( new QgsFieldExpressionWidget() ); + auto widget = std::make_unique(); widget->setLayer( layer ); const QSignalSpy spy( widget.get(), static_cast( &QgsFieldExpressionWidget::fieldChanged ) ); @@ -230,7 +230,7 @@ void TestQgsFieldExpressionWidget::testIsValid() QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "point?field=fld:int&field=name%20with%20space:string" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( layer ); - std::unique_ptr widget( new QgsFieldExpressionWidget() ); + auto widget = std::make_unique(); widget->setLayer( layer ); // also check the fieldChanged signal to ensure that the emitted bool isValid value is correct @@ -287,7 +287,7 @@ void TestQgsFieldExpressionWidget::testFilters() QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "point?field=intfld:int&field=stringfld:string&field=string2fld:string&field=longfld:long&field=doublefld:double&field=datefld:date&field=timefld:time&field=datetimefld:datetime&field=binaryfld:binary&field=booleanfld:boolean" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( layer ); - std::unique_ptr widget( new QgsFieldExpressionWidget() ); + auto widget = std::make_unique(); widget->setLayer( layer ); QCOMPARE( widget->mCombo->count(), 10 ); @@ -355,7 +355,7 @@ void TestQgsFieldExpressionWidget::setNull() QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "point?field=fld:int&field=fld2:int&field=fld3:int" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( layer ); - std::unique_ptr widget( new QgsFieldExpressionWidget() ); + auto widget = std::make_unique(); widget->setLayer( layer ); widget->setField( QString() ); diff --git a/tests/src/gui/testqgsfilewidget.cpp b/tests/src/gui/testqgsfilewidget.cpp index a141e29a05a..f1e1a0113b6 100644 --- a/tests/src/gui/testqgsfilewidget.cpp +++ b/tests/src/gui/testqgsfilewidget.cpp @@ -96,9 +96,9 @@ void TestQgsFileWidget::testDroppedFiles() w->setStorageMode( QgsFileWidget::GetFile ); // should not accept dropped folders - std::unique_ptr mime( new QMimeData() ); + auto mime = std::make_unique(); mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR ) ); - std::unique_ptr event( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + auto event = std::make_unique( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ); qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QVERIFY( w->lineEdit()->text().isEmpty() ); @@ -191,7 +191,7 @@ void TestQgsFileWidget::testMultipleFiles() QgsFileWidget *w = new QgsFileWidget(); w->setStorageMode( QgsFileWidget::GetMultipleFiles ); - std::unique_ptr mime( new QMimeData() ); + auto mime = std::make_unique(); mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/elev.gpx" ) ) ); const std::unique_ptr event( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); diff --git a/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp b/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp index a8d25e2d2f4..2efa972972d 100644 --- a/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp +++ b/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp @@ -1689,8 +1689,8 @@ void TestQgsValueRelationWidgetWrapper::testAllowMultiColumns() QFile::copy( myFileName + "/provider/test_json.gpkg", myTempDirName + "/test_json.gpkg" ); const QString myTempFileName = myTempDirName + "/test_json.gpkg"; const QFileInfo myMapFileInfo( myTempFileName ); - std::unique_ptr vl_text( new QgsVectorLayer( myMapFileInfo.filePath() + "|layername=foo", "test", QStringLiteral( "ogr" ) ) ); - std::unique_ptr vl_authors( new QgsVectorLayer( myMapFileInfo.filePath() + "|layername=author", "test", QStringLiteral( "ogr" ) ) ); + auto vl_text = std::make_unique( myMapFileInfo.filePath() + "|layername=foo", "test", QStringLiteral( "ogr" ) ); + auto vl_authors = std::make_unique( myMapFileInfo.filePath() + "|layername=author", "test", QStringLiteral( "ogr" ) ); QVERIFY( vl_text->isValid() ); QVERIFY( vl_authors->isValid() ); @@ -1737,8 +1737,8 @@ void TestQgsValueRelationWidgetWrapper::testAllowMultiAndCompleter() QFile::copy( myFileName + "/provider/test_json.gpkg", myTempDirName + "/test_json.gpkg" ); const QString myTempFileName = myTempDirName + "/test_json.gpkg"; const QFileInfo myMapFileInfo( myTempFileName ); - std::unique_ptr vl_text( new QgsVectorLayer( myMapFileInfo.filePath() + "|layername=foo", "test", QStringLiteral( "ogr" ) ) ); - std::unique_ptr vl_authors( new QgsVectorLayer( myMapFileInfo.filePath() + "|layername=author", "test", QStringLiteral( "ogr" ) ) ); + auto vl_text = std::make_unique( myMapFileInfo.filePath() + "|layername=foo", "test", QStringLiteral( "ogr" ) ); + auto vl_authors = std::make_unique( myMapFileInfo.filePath() + "|layername=author", "test", QStringLiteral( "ogr" ) ); QVERIFY( vl_text->isValid() ); QVERIFY( vl_authors->isValid() );