@@ -3721,13 +3721,13 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
3721
3721
if ( !fet->hasGeometry () )
3722
3722
return ;
3723
3723
3724
- std::unique_ptr<QgsAbstractGeometry> geom ( fet->geometry (). constGet ()-> clone () );
3724
+ QgsGeometry geom ( fet->geometry () );
3725
3725
if ( ct.isValid () )
3726
3726
{
3727
- geom-> transform ( ct );
3727
+ geom. transform ( ct );
3728
3728
}
3729
3729
3730
- QgsWkbTypes::Type geometryType = geom-> wkbType ();
3730
+ QgsWkbTypes::Type geometryType = geom. wkbType ();
3731
3731
3732
3732
QColor penColor;
3733
3733
QColor brushColor;
@@ -3763,13 +3763,13 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
3763
3763
// single point
3764
3764
if ( QgsWkbTypes::flatType ( geometryType ) == QgsWkbTypes::Point )
3765
3765
{
3766
- writePoint ( geom->coordinateSequence ().at ( 0 ).at ( 0 ).at ( 0 ), layer, penColor, ctx, symbolLayer, symbol, angle );
3766
+ writePoint ( geom. constGet () ->coordinateSequence ().at ( 0 ).at ( 0 ).at ( 0 ), layer, penColor, ctx, symbolLayer, symbol, angle );
3767
3767
return ;
3768
3768
}
3769
3769
3770
3770
if ( QgsWkbTypes::flatType ( geometryType ) == QgsWkbTypes::MultiPoint )
3771
3771
{
3772
- const QgsCoordinateSequence &cs = geom->coordinateSequence ();
3772
+ const QgsCoordinateSequence &cs = geom. constGet () ->coordinateSequence ();
3773
3773
for ( int i = 0 ; i < cs.size (); i++ )
3774
3774
{
3775
3775
writePoint ( cs.at ( i ).at ( 0 ).at ( 0 ), layer, penColor, ctx, symbolLayer, symbol, angle );
@@ -3779,49 +3779,52 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
3779
3779
3780
3780
if ( penStyle != Qt::NoPen )
3781
3781
{
3782
- const QgsAbstractGeometry *tempGeom = geom.get ();
3782
+ const QgsAbstractGeometry *sourceGeom = geom.constGet ();
3783
+ std::unique_ptr< QgsAbstractGeometry > tempGeom;
3783
3784
3784
3785
switch ( QgsWkbTypes::flatType ( geometryType ) )
3785
3786
{
3786
3787
case QgsWkbTypes::CircularString:
3787
3788
case QgsWkbTypes::CompoundCurve:
3788
- tempGeom = geom->segmentize ();
3789
+ tempGeom.reset ( geom.constGet ()->segmentize () );
3790
+ sourceGeom = tempGeom.get ();
3789
3791
if ( !tempGeom )
3790
3792
break ;
3791
3793
FALLTHROUGH
3792
3794
case QgsWkbTypes::LineString:
3793
3795
if ( !qgsDoubleNear ( offset, 0.0 ) )
3794
3796
{
3795
- QgsGeos geos ( tempGeom );
3796
- if ( tempGeom != geom. get ( ) )
3797
- delete tempGeom;
3798
- tempGeom = geos. offsetCurve ( offset, 0 , GEOSBUF_JOIN_MITRE, 2.0 ); // #spellok
3799
- if ( !tempGeom )
3800
- tempGeom = geom.get ();
3797
+ QgsGeos geos ( sourceGeom );
3798
+ tempGeom. reset ( geos. offsetCurve ( offset, 0 , GEOSBUF_JOIN_MITRE, 2.0 ) ); // #spellok
3799
+ if ( tempGeom )
3800
+ sourceGeom = tempGeom. get ();
3801
+ else
3802
+ sourceGeom = geom.constGet ();
3801
3803
}
3802
3804
3803
- writePolyline ( tempGeom ->coordinateSequence ().at ( 0 ).at ( 0 ), layer, lineStyleName, penColor, width );
3805
+ writePolyline ( sourceGeom ->coordinateSequence ().at ( 0 ).at ( 0 ), layer, lineStyleName, penColor, width );
3804
3806
3805
3807
break ;
3806
3808
3807
3809
case QgsWkbTypes::MultiCurve:
3808
- tempGeom = geom->segmentize ();
3810
+ tempGeom. reset ( geom. constGet () ->segmentize () );
3809
3811
if ( !tempGeom )
3810
3812
break ;
3813
+ sourceGeom = tempGeom.get ();
3811
3814
FALLTHROUGH
3812
3815
case QgsWkbTypes::MultiLineString:
3813
3816
{
3814
3817
if ( !qgsDoubleNear ( offset, 0.0 ) )
3815
3818
{
3816
- QgsGeos geos ( tempGeom );
3817
- if ( tempGeom != geom. get ( ) )
3818
- delete tempGeom;
3819
- tempGeom = geos. offsetCurve ( offset, 0 , GEOSBUF_JOIN_MITRE, 2.0 ); // #spellok
3820
- if ( !tempGeom )
3821
- tempGeom = geom.get ();
3819
+ QgsGeos geos ( sourceGeom );
3820
+ tempGeom. reset ( geos. offsetCurve ( offset, 0 , GEOSBUF_JOIN_MITRE, 2.0 ) ); // #spellok
3821
+ if ( tempGeom )
3822
+ sourceGeom = tempGeom. get ();
3823
+ else
3824
+ sourceGeom = geom.constGet ();
3822
3825
}
3823
3826
3824
- const QgsCoordinateSequence &cs = tempGeom ->coordinateSequence ();
3827
+ const QgsCoordinateSequence &cs = sourceGeom ->coordinateSequence ();
3825
3828
for ( int i = 0 ; i < cs.size (); i++ )
3826
3829
{
3827
3830
writePolyline ( cs.at ( i ).at ( 0 ), layer, lineStyleName, penColor, width );
@@ -3831,23 +3834,24 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
3831
3834
}
3832
3835
3833
3836
case QgsWkbTypes::CurvePolygon:
3834
- tempGeom = geom->segmentize ();
3837
+ tempGeom. reset ( geom. constGet () ->segmentize () );
3835
3838
if ( !tempGeom )
3836
3839
break ;
3840
+ sourceGeom = tempGeom.get ();
3837
3841
FALLTHROUGH
3838
3842
case QgsWkbTypes::Polygon:
3839
3843
{
3840
3844
if ( !qgsDoubleNear ( offset, 0.0 ) )
3841
3845
{
3842
- QgsGeos geos ( tempGeom );
3843
- if ( tempGeom != geom. get ( ) )
3844
- delete tempGeom;
3845
- tempGeom = geos. buffer ( offset, 0 , GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 ); // #spellok
3846
- if ( !tempGeom )
3847
- tempGeom = geom.get ();
3846
+ QgsGeos geos ( sourceGeom );
3847
+ tempGeom. reset ( geos. buffer ( offset, 0 , GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 ) ); // #spellok
3848
+ if ( tempGeom )
3849
+ sourceGeom = tempGeom. get ();
3850
+ else
3851
+ sourceGeom = geom.constGet ();
3848
3852
}
3849
3853
3850
- const QgsCoordinateSequence &cs = tempGeom ->coordinateSequence ();
3854
+ const QgsCoordinateSequence &cs = sourceGeom ->coordinateSequence ();
3851
3855
for ( int i = 0 ; i < cs.at ( 0 ).size (); i++ )
3852
3856
{
3853
3857
writePolyline ( cs.at ( 0 ).at ( i ), layer, lineStyleName, penColor, width );
@@ -3857,23 +3861,24 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
3857
3861
}
3858
3862
3859
3863
case QgsWkbTypes::MultiSurface:
3860
- tempGeom = geom->segmentize ();
3864
+ tempGeom. reset ( geom. constGet () ->segmentize () );
3861
3865
if ( !tempGeom )
3862
3866
break ;
3867
+ sourceGeom = tempGeom.get ();
3863
3868
FALLTHROUGH
3864
3869
case QgsWkbTypes::MultiPolygon:
3865
3870
{
3866
3871
if ( !qgsDoubleNear ( offset, 0.0 ) )
3867
3872
{
3868
- QgsGeos geos ( tempGeom );
3869
- if ( tempGeom != geom. get ( ) )
3870
- delete tempGeom;
3871
- tempGeom = geos. buffer ( offset, 0 , GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 ); // #spellok
3872
- if ( !tempGeom )
3873
- tempGeom = geom.get ();
3873
+ QgsGeos geos ( sourceGeom );
3874
+ tempGeom. reset ( geos. buffer ( offset, 0 , GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 ) ); // #spellok
3875
+ if ( tempGeom )
3876
+ sourceGeom = tempGeom. get ();
3877
+ else
3878
+ sourceGeom = geom.constGet ();
3874
3879
}
3875
3880
3876
- const QgsCoordinateSequence &cs = tempGeom ->coordinateSequence ();
3881
+ const QgsCoordinateSequence &cs = sourceGeom ->coordinateSequence ();
3877
3882
for ( int i = 0 ; i < cs.size (); i++ )
3878
3883
for ( int j = 0 ; j < cs.at ( i ).size (); j++ )
3879
3884
writePolyline ( cs.at ( i ).at ( j ), layer, lineStyleName, penColor, width );
@@ -3885,33 +3890,34 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
3885
3890
break ;
3886
3891
}
3887
3892
3888
- if ( tempGeom != geom.get () )
3889
- delete tempGeom;
3890
3893
}
3891
3894
3892
3895
if ( brushStyle != Qt::NoBrush )
3893
3896
{
3894
- const QgsAbstractGeometry *tempGeom = geom.get ();
3897
+ const QgsAbstractGeometry *sourceGeom = geom.constGet ();
3898
+ std::unique_ptr< QgsAbstractGeometry > tempGeom;
3895
3899
3896
3900
switch ( QgsWkbTypes::flatType ( geometryType ) )
3897
3901
{
3898
3902
case QgsWkbTypes::CurvePolygon:
3899
- tempGeom = tempGeom ->segmentize ();
3903
+ tempGeom. reset ( geom. constGet () ->segmentize () );
3900
3904
if ( !tempGeom )
3901
3905
break ;
3906
+ sourceGeom = tempGeom.get ();
3902
3907
FALLTHROUGH
3903
3908
case QgsWkbTypes::Polygon:
3904
- writePolygon ( tempGeom ->coordinateSequence ().at ( 0 ), layer, QStringLiteral ( " SOLID" ), brushColor );
3909
+ writePolygon ( sourceGeom ->coordinateSequence ().at ( 0 ), layer, QStringLiteral ( " SOLID" ), brushColor );
3905
3910
break ;
3906
3911
3907
3912
case QgsWkbTypes::MultiSurface:
3908
- tempGeom = tempGeom ->segmentize ();
3913
+ tempGeom. reset ( geom. constGet () ->segmentize () );
3909
3914
if ( !tempGeom )
3910
3915
break ;
3916
+ sourceGeom = tempGeom.get ();
3911
3917
FALLTHROUGH
3912
3918
case QgsWkbTypes::MultiPolygon:
3913
3919
{
3914
- const QgsCoordinateSequence &cs = tempGeom ->coordinateSequence ();
3920
+ const QgsCoordinateSequence &cs = sourceGeom ->coordinateSequence ();
3915
3921
for ( int i = 0 ; i < cs.size (); i++ )
3916
3922
{
3917
3923
writePolygon ( cs.at ( i ), layer, QStringLiteral ( " SOLID" ), brushColor );
@@ -3923,9 +3929,6 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
3923
3929
break ;
3924
3930
3925
3931
}
3926
-
3927
- if ( tempGeom != geom.get () )
3928
- delete tempGeom;
3929
3932
}
3930
3933
}
3931
3934
0 commit comments