Skip to content
Permalink
Browse files
fix offset curve crash (fixes #9446)
  • Loading branch information
jef-n committed Feb 8, 2014
1 parent 188b373 commit 417d49701770ab59938c3fcdc9f52d405f65d9ae
Showing with 19 additions and 5 deletions.
  1. +13 −5 src/app/qgsmaptooloffsetcurve.cpp
  2. +6 −0 src/gui/qgsrubberband.cpp
@@ -25,8 +25,16 @@
#include <QMouseEvent>
#include "qgisapp.h"

QgsMapToolOffsetCurve::QgsMapToolOffsetCurve( QgsMapCanvas* canvas ): QgsMapToolEdit( canvas ), mRubberBand( 0 ),
mOriginalGeometry( 0 ), mGeometryModified( false ), mDistanceItem( 0 ), mDistanceSpinBox( 0 ), mSnapVertexMarker( 0 ), mForceCopy( false ), mMultiPartGeometry( false )
QgsMapToolOffsetCurve::QgsMapToolOffsetCurve( QgsMapCanvas* canvas )
: QgsMapToolEdit( canvas )
, mRubberBand( 0 )
, mOriginalGeometry( 0 )
, mGeometryModified( false )
, mDistanceItem( 0 )
, mDistanceSpinBox( 0 )
, mSnapVertexMarker( 0 )
, mForceCopy( false )
, mMultiPartGeometry( false )
{
}

@@ -154,7 +162,7 @@ void QgsMapToolOffsetCurve::placeOffsetCurveToValue()
{
//is rubber band left or right of original geometry
double leftOf = 0;
const QgsPoint* firstPoint = mRubberBand->getPoint( 0 );
const QgsPoint *firstPoint = mRubberBand->getPoint( 0 );
if ( firstPoint )
{
QgsPoint minDistPoint;
@@ -236,6 +244,7 @@ QgsGeometry* QgsMapToolOffsetCurve::createOriginGeometry( QgsVectorLayer* vl, co
{
return 0;
}

mMultiPartGeometry = false;
//assign feature part by vertex number (snap to vertex) or by before vertex number (snap to segment)
int partVertexNr = ( sr.snappedVertexNr == -1 ? sr.beforeVertexNr : sr.snappedVertexNr );
@@ -254,7 +263,6 @@ QgsGeometry* QgsMapToolOffsetCurve::createOriginGeometry( QgsVectorLayer* vl, co
return linestringFromPolygon( snappedFeature.geometry(), partVertexNr );
}


//for background layers, try to merge selected entries together if snapped feature is contained in selection
const QgsFeatureIds& selection = vl->selectedFeaturesIds();
if ( selection.size() < 1 || !selection.contains( sr.snappedAtGeometry ) )
@@ -273,7 +281,7 @@ QgsGeometry* QgsMapToolOffsetCurve::createOriginGeometry( QgsVectorLayer* vl, co
geom = geom->combine( selIt->geometry() );
}

//if multitype, return only the snaped to geometry
//if multitype, return only the snapped to geometry
if ( geom->isMultipart() )
{
delete geom;
@@ -236,6 +236,12 @@ void QgsRubberBand::movePoint( int index, const QgsPoint& p, int geometryIndex )

void QgsRubberBand::setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer )
{
if( !geom )
{
reset( mGeometryType );
return;
}

reset( geom->type() );
addGeometry( geom, layer );
}

0 comments on commit 417d497

Please sign in to comment.