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