Skip to content
Permalink
Browse files

Remove geometry if deleting a point feature vertex with the node tool…

…. Make nodetool more robust against NULL geometries
  • Loading branch information
mhugent committed Sep 8, 2015
1 parent 73ffb83 commit eb793a758a0fc9aaa25aefb373de22588a48e786
@@ -337,6 +337,10 @@ void QgsMapToolNodeTool::safeSelectVertex( int vertexNr )
if ( mSelectedFeature )
{
int n = mSelectedFeature->vertexMap().size();
if ( n < 1 )
{
return;
}
mSelectedFeature->selectVertex(( vertexNr + n ) % n );
}
}
@@ -40,7 +40,7 @@ class CoordinateItemDelegate : public QStyledItemDelegate
QString displayText( const QVariant & value, const QLocale & locale ) const override
{
return locale.toString( value.toDouble(), 'f', 4 );
}
}

protected:

@@ -49,19 +49,19 @@ class CoordinateItemDelegate : public QStyledItemDelegate
QLineEdit* lineEdit = new QLineEdit( parent );
QDoubleValidator* validator = new QDoubleValidator();
if ( !index.data( MinRadiusRole ).isNull() )
validator->setBottom( index.data( MinRadiusRole ).toDouble() );
validator->setBottom( index.data( MinRadiusRole ).toDouble() );
lineEdit->setValidator( validator );
return lineEdit;
}

void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override
{
QLineEdit* lineEdit = qobject_cast<QLineEdit*>( editor );
if ( lineEdit->hasAcceptableInput() )
{
QStyledItemDelegate::setModelData( editor, model, index );
QLineEdit* lineEdit = qobject_cast<QLineEdit*>( editor );
if ( lineEdit->hasAcceptableInput() )
{
QStyledItemDelegate::setModelData( editor, model, index );
}
}
}
};


@@ -170,8 +170,8 @@ void QgsNodeEditor::rebuildTable()

++row;
}
mTableWidget->setColumnHidden( 3, !mSelectedFeature->vertexMap()[0]->point().is3D() );
mTableWidget->setColumnHidden( 4, !mSelectedFeature->vertexMap()[0]->point().isMeasure() );
mTableWidget->setColumnHidden( 3, mSelectedFeature->vertexMap().size() < 1 || !mSelectedFeature->vertexMap()[0]->point().is3D() );
mTableWidget->setColumnHidden( 4, mSelectedFeature->vertexMap().size() < 1 || !mSelectedFeature->vertexMap()[0]->point().isMeasure() );
mTableWidget->setColumnHidden( 5, !hasR );
mTableWidget->resizeColumnToContents( 0 );
mTableWidget->blockSignals( false );
@@ -405,7 +405,7 @@ void QgsSelectedFeature::createVertexMap()
updateGeometry( 0 );
}

if ( !mGeometry )
if ( !mGeometry || !mGeometry->geometry() )
{
return;
}
@@ -438,6 +438,16 @@ bool QgsGeometry::deleteVertex( int atVertex )
return false;
}

//if it is a point, set the geometry to NULL
if ( QgsWKBTypes::flatType( d->geometry->wkbType() ) == QgsWKBTypes::Point )
{
detach( false );
delete d->geometry;
removeWkbGeos();
d->geometry = 0;
return true;
}

QgsVertexId id;
if ( !vertexIdFromVertexNr( atVertex, id ) )
{

0 comments on commit eb793a7

Please sign in to comment.
You can’t perform that action at this time.