Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "auto" for std::unique_ptr<X> = std::make_unique<X> #60502

Merged
merged 5 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ The multipoint Z and M type will be set based on the type of the first point in
break;
}

std::unique_ptr< QgsPoint > point = std::make_unique< QgsPoint >( x, y );
auto point = std::make_unique< QgsPoint >( x, y );
if ( elementSize > 2 )
{
element = PySequence_GetItem( value, 2 );
Expand Down
2 changes: 1 addition & 1 deletion python/PyQt6/core/auto_generated/qgsfeatureiterator.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Wrapper for iterator of features from vector data provider or vector layer

SIP_PYOBJECT __next__() /TypeHint="QgsFeature"/;
%MethodCode
std::unique_ptr< QgsFeature > f = std::make_unique< QgsFeature >();
auto f = std::make_unique< QgsFeature >();
bool result = false;
Py_BEGIN_ALLOW_THREADS
result = ( sipCpp->nextFeature( *f ) );
Expand Down
2 changes: 1 addition & 1 deletion python/PyQt6/core/auto_generated/qgsspatialindex.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Geometry is only stored if the QgsSpatialIndex was created with the FlagStoreFea
.. versionadded:: 3.6
%End
%MethodCode
std::unique_ptr< QgsGeometry > g = std::make_unique< QgsGeometry >( sipCpp->geometry( a0 ) );
auto g = std::make_unique< QgsGeometry >( sipCpp->geometry( a0 ) );
if ( g->isNull() )
{
PyErr_SetString( PyExc_KeyError, QStringLiteral( "No geometry with feature id %1 exists in the index." ).arg( a0 ).toUtf8().constData() );
Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/geometry/qgsmultipoint.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ The multipoint Z and M type will be set based on the type of the first point in
break;
}

std::unique_ptr< QgsPoint > point = std::make_unique< QgsPoint >( x, y );
auto point = std::make_unique< QgsPoint >( x, y );
if ( elementSize > 2 )
{
element = PySequence_GetItem( value, 2 );
Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/qgsfeatureiterator.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Wrapper for iterator of features from vector data provider or vector layer

SIP_PYOBJECT __next__() /TypeHint="QgsFeature"/;
%MethodCode
std::unique_ptr< QgsFeature > f = std::make_unique< QgsFeature >();
auto f = std::make_unique< QgsFeature >();
bool result = false;
Py_BEGIN_ALLOW_THREADS
result = ( sipCpp->nextFeature( *f ) );
Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/qgsspatialindex.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Geometry is only stored if the QgsSpatialIndex was created with the FlagStoreFea
.. versionadded:: 3.6
%End
%MethodCode
std::unique_ptr< QgsGeometry > g = std::make_unique< QgsGeometry >( sipCpp->geometry( a0 ) );
auto g = std::make_unique< QgsGeometry >( sipCpp->geometry( a0 ) );
if ( g->isNull() )
{
PyErr_SetString( PyExc_KeyError, QStringLiteral( "No geometry with feature id %1 exists in the index." ).arg( a0 ).toUtf8().constData() );
Expand Down
40 changes: 36 additions & 4 deletions scripts/qstringfixup.py → scripts/code_fixup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
###########################################################################
# qstringfixup.py
# code_fixup.py
# ---------------
# Date : October 2020
# Copyright : (C) 2020 by Even Rouault
Expand All @@ -26,14 +26,15 @@
# DEALINGS IN THE SOFTWARE.
###########################################################################

# This script fixes several suboptimal uses of QStringLiteral where QLatin1String would be better
# This script fixes several suboptimal uses of QStringLiteral where QLatin1String would be better,
# and other auto code-cleaning operations (such as use of auto with std::make_unique)
# It is not automatically run yet.

# Run it on whole code base with:
# ../scripts/qstringfixup.sh --all
# ../scripts/code_fixup.sh --all

# or on modified files only with:
# ../scripts/qstringfixup.sh
# ../scripts/code_fixup.sh

import re
import sys
Expand Down Expand Up @@ -93,6 +94,16 @@
r"""(.*)(.startsWith\(|.endsWith\(|.indexOf\(|.lastIndexOf\(|\+=) QLatin1String\( ("[^"]") \)(.*)"""
)

make_unique_shared = re.compile(
r"""^(\s*)std::(?:unique|shared)_ptr<\s*(.*?)\s*>(\s*.*?\s*=\s*std::make_(?:unique|shared)<\s*(.*?)\s*>.*)$"""
)
make_unique_shared2 = re.compile(
r"""^(\s*)std::(?:unique|shared)_ptr<\s*(.*?)\s*>(?:\s*(.*?)\s*\()\s*(std::make_(?:unique|shared)<\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):
"""x is a double quoted string"""
Expand Down Expand Up @@ -225,5 +236,26 @@ def qlatin1char_or_string(x):
else:
break

m = make_unique_shared.match(line)
if m and m.group(2) == m.group(4):
line = m.group(1) + "auto" + m.group(3)

m = make_unique_shared2.match(line)
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
6 changes: 3 additions & 3 deletions scripts/qstringfixup.sh → scripts/code_fixup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
###########################################################################
# qstringfixup.sh
# code_fixup.sh
# ---------------
# Date : October 2020
# Copyright : (C) 2020 by Even Rouault
Expand Down Expand Up @@ -59,8 +59,8 @@ for f in $MODIFIED; do
;;
esac

m=$f.qstringfixup
python "${TOPLEVEL}/scripts/qstringfixup.py" "$f" > "$m"
m=$f.code_fixup
python "${TOPLEVEL}/scripts/code_fixup.py" "$f" > "$m"
if diff -u "$m" "$f" >/dev/null; then
# no difference found
rm "$m"
Expand Down
2 changes: 1 addition & 1 deletion src/3d/mesh/qgsmesh3dmaterial_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void QgsMesh3DMaterial::configureArrows( QgsMeshLayer *layer, const QgsDateTimeR
QVector<QgsVector> vectors( 1 );
QSize gridSize( 1, 1 );
QgsPointXY minCorner;
std::unique_ptr<Qt3DRender::QParameter> arrowsEnabledParameter = std::make_unique<Qt3DRender::QParameter>( "arrowsEnabled", nullptr );
auto arrowsEnabledParameter = std::make_unique<Qt3DRender::QParameter>( "arrowsEnabled", nullptr );
if ( !layer || mMagnitudeType != MagnitudeType::ScalarDataSet || !mSymbol->arrowsEnabled() || meta.isScalar() || !datasetIndex.isValid() )
arrowsEnabledParameter->setValue( false );
else
Expand Down
6 changes: 3 additions & 3 deletions src/3d/qgs3dmapsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte
QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
while ( !elemPointLight.isNull() )
{
std::unique_ptr<QgsPointLightSettings> pointLight = std::make_unique<QgsPointLightSettings>();
auto pointLight = std::make_unique<QgsPointLightSettings>();
pointLight->readXml( elemPointLight, context );
mLightSources << pointLight.release();
elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
Expand All @@ -209,7 +209,7 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte
else
{
// QGIS <= 3.4 did not have light configuration
std::unique_ptr<QgsPointLightSettings> defaultLight = std::make_unique<QgsPointLightSettings>();
auto defaultLight = std::make_unique<QgsPointLightSettings>();
defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
mLightSources << defaultLight.release();
}
Expand All @@ -220,7 +220,7 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte
QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( QStringLiteral( "directional-light" ) );
while ( !elemDirectionalLight.isNull() )
{
std::unique_ptr<QgsDirectionalLightSettings> directionalLight = std::make_unique<QgsDirectionalLightSettings>();
auto directionalLight = std::make_unique<QgsDirectionalLightSettings>();
directionalLight->readXml( elemDirectionalLight, context );
mLightSources << directionalLight.release();
elemDirectionalLight = elemDirectionalLight.nextSiblingElement( QStringLiteral( "directional-light" ) );
Expand Down
2 changes: 1 addition & 1 deletion src/3d/qgs3dutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ std::unique_ptr<QgsPointCloudLayer3DRenderer> Qgs3DUtils::convert2DPointCloudRen

if ( symbol3D )
{
std::unique_ptr<QgsPointCloudLayer3DRenderer> renderer3D = std::make_unique<QgsPointCloudLayer3DRenderer>();
auto renderer3D = std::make_unique<QgsPointCloudLayer3DRenderer>();
renderer3D->setSymbol( symbol3D.release() );
return renderer3D;
}
Expand Down
2 changes: 1 addition & 1 deletion src/3d/symbols/qgsline3dsymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ QgsLine3DSymbol::~QgsLine3DSymbol() = default;

QgsAbstract3DSymbol *QgsLine3DSymbol::clone() const
{
std::unique_ptr<QgsLine3DSymbol> result = std::make_unique<QgsLine3DSymbol>();
auto result = std::make_unique<QgsLine3DSymbol>();
result->mAltClamping = mAltClamping;
result->mAltBinding = mAltBinding;
result->mWidth = mWidth;
Expand Down
2 changes: 1 addition & 1 deletion src/3d/symbols/qgsmesh3dsymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ QgsMesh3DSymbol::~QgsMesh3DSymbol() = default;

QgsMesh3DSymbol *QgsMesh3DSymbol::clone() const
{
std::unique_ptr<QgsMesh3DSymbol> result = std::make_unique<QgsMesh3DSymbol>();
auto result = std::make_unique<QgsMesh3DSymbol>();

result->mAltClamping = mAltClamping;
result->mHeight = mHeight;
Expand Down
2 changes: 1 addition & 1 deletion src/3d/symbols/qgspolygon3dsymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ QgsPolygon3DSymbol::~QgsPolygon3DSymbol() = default;

QgsAbstract3DSymbol *QgsPolygon3DSymbol::clone() const
{
std::unique_ptr<QgsPolygon3DSymbol> result = std::make_unique<QgsPolygon3DSymbol>();
auto result = std::make_unique<QgsPolygon3DSymbol>();
result->mAltClamping = mAltClamping;
result->mAltBinding = mAltBinding;
result->mOffset = mOffset;
Expand Down
8 changes: 4 additions & 4 deletions src/3d/terrain/qgs3dterrainregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ QgsAbstractTerrainSettings *Qgs3DTerrainRegistry::configureTerrainFromProject( Q
{
if ( properties->terrainProvider()->type() == QLatin1String( "flat" ) )
{
std::unique_ptr<QgsFlatTerrainSettings> flatTerrain = std::make_unique<QgsFlatTerrainSettings>();
auto flatTerrain = std::make_unique<QgsFlatTerrainSettings>();
flatTerrain->setElevationOffset( properties->terrainProvider()->offset() );
return flatTerrain.release();
}
else if ( properties->terrainProvider()->type() == QLatin1String( "raster" ) )
{
QgsRasterDemTerrainProvider *rasterProvider = qgis::down_cast<QgsRasterDemTerrainProvider *>( properties->terrainProvider() );

std::unique_ptr<QgsDemTerrainSettings> demTerrain = std::make_unique<QgsDemTerrainSettings>();
auto demTerrain = std::make_unique<QgsDemTerrainSettings>();
demTerrain->setLayer( rasterProvider->layer() );
demTerrain->setElevationOffset( properties->terrainProvider()->offset() );
demTerrain->setVerticalScale( properties->terrainProvider()->scale() );
Expand All @@ -94,15 +94,15 @@ QgsAbstractTerrainSettings *Qgs3DTerrainRegistry::configureTerrainFromProject( Q
{
QgsMeshTerrainProvider *meshProvider = qgis::down_cast<QgsMeshTerrainProvider *>( properties->terrainProvider() );

std::unique_ptr<QgsMeshTerrainSettings> meshTerrain = std::make_unique<QgsMeshTerrainSettings>();
auto meshTerrain = std::make_unique<QgsMeshTerrainSettings>();
meshTerrain->setLayer( meshProvider->layer() );
meshTerrain->setElevationOffset( properties->terrainProvider()->offset() );
meshTerrain->setVerticalScale( properties->terrainProvider()->scale() );
return meshTerrain.release();
}
else
{
std::unique_ptr<QgsFlatTerrainSettings> flatTerrain = std::make_unique<QgsFlatTerrainSettings>();
auto flatTerrain = std::make_unique<QgsFlatTerrainSettings>();
return flatTerrain.release();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/3d/terrain/qgsdemterrainsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool QgsDemTerrainSettings::equals( const QgsAbstractTerrainSettings *other ) co

std::unique_ptr<QgsTerrainGenerator> QgsDemTerrainSettings::createTerrainGenerator( const Qgs3DRenderContext &context ) const
{
std::unique_ptr<QgsDemTerrainGenerator> generator = std::make_unique<QgsDemTerrainGenerator>();
auto generator = std::make_unique<QgsDemTerrainGenerator>();
generator->setCrs( context.crs(), context.transformContext() );
generator->setExtent( context.extent() );
generator->setLayer( layer() );
Expand Down
2 changes: 1 addition & 1 deletion src/3d/terrain/qgsflatterrainsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool QgsFlatTerrainSettings::equals( const QgsAbstractTerrainSettings *other ) c

std::unique_ptr<QgsTerrainGenerator> QgsFlatTerrainSettings::createTerrainGenerator( const Qgs3DRenderContext &context ) const
{
std::unique_ptr<QgsFlatTerrainGenerator> generator = std::make_unique<QgsFlatTerrainGenerator>();
auto generator = std::make_unique<QgsFlatTerrainGenerator>();
generator->setCrs( context.crs(), context.transformContext() );
generator->setExtent( context.extent() );
return generator;
Expand Down
4 changes: 2 additions & 2 deletions src/3d/terrain/qgsmeshterrainsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ QgsMeshTerrainSettings::~QgsMeshTerrainSettings() = default;

QgsMeshTerrainSettings *QgsMeshTerrainSettings::clone() const
{
std::unique_ptr<QgsMeshTerrainSettings> cloned = std::make_unique<QgsMeshTerrainSettings>();
auto cloned = std::make_unique<QgsMeshTerrainSettings>();
cloned->mSymbol.reset( mSymbol->clone() );
cloned->mLayer = mLayer;
cloned->copyCommonProperties( this );
Expand Down Expand Up @@ -97,7 +97,7 @@ bool QgsMeshTerrainSettings::equals( const QgsAbstractTerrainSettings *other ) c

std::unique_ptr<QgsTerrainGenerator> QgsMeshTerrainSettings::createTerrainGenerator( const Qgs3DRenderContext &context ) const
{
std::unique_ptr<QgsMeshTerrainGenerator> generator = std::make_unique<QgsMeshTerrainGenerator>();
auto generator = std::make_unique<QgsMeshTerrainGenerator>();
generator->setLayer( layer() );
std::unique_ptr<QgsMesh3DSymbol> symbol( mSymbol->clone() );
symbol->setVerticalScale( verticalScale() );
Expand Down
2 changes: 1 addition & 1 deletion src/3d/terrain/qgsonlinedemterrainsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool QgsOnlineDemTerrainSettings::equals( const QgsAbstractTerrainSettings *othe

std::unique_ptr<QgsTerrainGenerator> QgsOnlineDemTerrainSettings::createTerrainGenerator( const Qgs3DRenderContext &context ) const
{
std::unique_ptr<QgsOnlineTerrainGenerator> generator = std::make_unique<QgsOnlineTerrainGenerator>();
auto generator = std::make_unique<QgsOnlineTerrainGenerator>();
generator->setResolution( mResolution );
generator->setSkirtHeight( static_cast<float>( mSkirtHeight ) );
generator->setCrs( context.crs(), context.transformContext() );
Expand Down
2 changes: 1 addition & 1 deletion src/3d/terrain/qgsquantizedmeshterrainsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool QgsQuantizedMeshTerrainSettings::equals( const QgsAbstractTerrainSettings *

std::unique_ptr<QgsTerrainGenerator> QgsQuantizedMeshTerrainSettings::createTerrainGenerator( const Qgs3DRenderContext &context ) const
{
std::unique_ptr<QgsQuantizedMeshTerrainGenerator> generator = std::make_unique<QgsQuantizedMeshTerrainGenerator>();
auto generator = std::make_unique<QgsQuantizedMeshTerrainGenerator>();
generator->setLayer( layer() );
generator->setCrs( context.crs(), context.transformContext() );
generator->setExtent( context.extent() );
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/georeferencing/qgsgcptransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ bool QgsLinearGeorefTransform::getOriginScale( QgsPointXY &origin, double &scale

QgsGcpTransformerInterface *QgsLinearGeorefTransform::clone() const
{
std::unique_ptr<QgsLinearGeorefTransform> res = std::make_unique<QgsLinearGeorefTransform>();
auto res = std::make_unique<QgsLinearGeorefTransform>();
res->mParameters = mParameters;
return res.release();
}
Expand Down Expand Up @@ -234,7 +234,7 @@ bool QgsHelmertGeorefTransform::getOriginScaleRotation( QgsPointXY &origin, doub

QgsGcpTransformerInterface *QgsHelmertGeorefTransform::clone() const
{
std::unique_ptr<QgsHelmertGeorefTransform> res = std::make_unique<QgsHelmertGeorefTransform>();
auto res = std::make_unique<QgsHelmertGeorefTransform>();
res->mHelmertParameters = mHelmertParameters;
return res.release();
}
Expand Down Expand Up @@ -329,7 +329,7 @@ QgsGDALGeorefTransform::~QgsGDALGeorefTransform()

QgsGcpTransformerInterface *QgsGDALGeorefTransform::clone() const
{
std::unique_ptr<QgsGDALGeorefTransform> res = std::make_unique<QgsGDALGeorefTransform>( mIsTPSTransform, mPolynomialOrder );
auto res = std::make_unique<QgsGDALGeorefTransform>( mIsTPSTransform, mPolynomialOrder );
res->updateParametersFromGcps( mSourceCoords, mDestCoordinates, mInvertYAxis );
return res.release();
}
Expand Down Expand Up @@ -436,7 +436,7 @@ QgsProjectiveGeorefTransform::QgsProjectiveGeorefTransform()

QgsGcpTransformerInterface *QgsProjectiveGeorefTransform::clone() const
{
std::unique_ptr<QgsProjectiveGeorefTransform> res = std::make_unique<QgsProjectiveGeorefTransform>();
auto res = std::make_unique<QgsProjectiveGeorefTransform>();
res->mParameters = mParameters;
return res.release();
}
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/interpolation/qgsgridfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int QgsGridFileWriter::writeFile( QgsFeedback *feedback )
QgsInterpolator::LayerData ld = mInterpolator->layerData().at( 0 );
const QgsCoordinateReferenceSystem crs = ld.source->sourceCrs();

std::unique_ptr<QgsRasterFileWriter> writer = std::make_unique<QgsRasterFileWriter>( mOutputFilePath );
auto writer = std::make_unique<QgsRasterFileWriter>( mOutputFilePath );
writer->setOutputProviderKey( QStringLiteral( "gdal" ) );
writer->setOutputFormat( outputFormat );

Expand Down
14 changes: 7 additions & 7 deletions src/analysis/mesh/qgsmeshcontours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ QgsGeometry QgsMeshContours::exportPolygons( double min_value, double max_value,
{
QVector<QgsMeshVertex> ring = coords;
ring.push_back( coords[0] );
std::unique_ptr<QgsLineString> ext = std::make_unique<QgsLineString>( coords );
std::unique_ptr<QgsPolygon> poly = std::make_unique<QgsPolygon>();
auto ext = std::make_unique<QgsLineString>( coords );
auto poly = std::make_unique<QgsPolygon>();
poly->setExteriorRing( ext.release() );
multiPolygon.push_back( QgsGeometry( std::move( poly ) ) );
continue;
Expand Down Expand Up @@ -236,8 +236,8 @@ QgsGeometry QgsMeshContours::exportPolygons( double min_value, double max_value,
// add if the polygon is not degraded
if ( ring.size() > 2 )
{
std::unique_ptr<QgsLineString> ext = std::make_unique<QgsLineString>( ring );
std::unique_ptr<QgsPolygon> poly = std::make_unique<QgsPolygon>();
auto ext = std::make_unique<QgsLineString>( ring );
auto poly = std::make_unique<QgsPolygon>();
poly->setExteriorRing( ext.release() );
multiPolygon.push_back( QgsGeometry( std::move( poly ) ) );
}
Expand Down Expand Up @@ -268,7 +268,7 @@ QgsGeometry QgsMeshContours::exportLines( const QgsMeshDatasetIndex &index, doub

QgsGeometry QgsMeshContours::exportLines( double value, QgsFeedback *feedback )
{
std::unique_ptr<QgsMultiLineString> multiLineString( new QgsMultiLineString() );
auto multiLineString = std::make_unique<QgsMultiLineString>();
QSet<QPair<int, int>> exactEdges;

// STEP 1: Get Data
Expand Down Expand Up @@ -337,7 +337,7 @@ QgsGeometry QgsMeshContours::exportLines( double value, QgsFeedback *feedback )
else
{
exactEdges.insert( { indices[i], indices[j] } );
std::unique_ptr<QgsLineString> line( new QgsLineString( coords[i], coords[j] ) );
auto line = std::make_unique<QgsLineString>( coords[i], coords[j] );
multiLineString->addGeometry( line.release() );
break;
}
Expand All @@ -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<QgsLineString> line( new QgsLineString( tmp, xy ) );
auto line = std::make_unique<QgsLineString>( tmp, xy );
multiLineString->addGeometry( line.release() );
break;
}
Expand Down
Loading
Loading