Skip to content

Commit

Permalink
Add some safety checks
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 30, 2016
1 parent 51c62c1 commit 81d4f61
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/featuremodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ void FeatureModel::setAttribute( int fieldIndex, const QVariant& value )

bool FeatureModel::save()
{
if ( !mFeature.layer() )
return false;

mFeature.layer()->startEditing();
QgsFeature feat = mFeature.qgsFeature();
mFeature.layer()->updateFeature( feat );
Expand All @@ -150,11 +153,17 @@ bool FeatureModel::save()

void FeatureModel::reset()
{
if ( !mFeature.layer() )
return;

mFeature.layer()->rollBack();
}

bool FeatureModel::suppressFeatureForm() const
{
if ( !mFeature.layer() )
return false;

return mFeature.layer()->editFormConfig()->suppress();
}

Expand All @@ -178,6 +187,9 @@ void FeatureModel::applyGeometry()

void FeatureModel::create()
{
if ( !mFeature.layer() )
return;

mFeature.layer()->startEditing(); // better safe than sorry
mFeature.create();
}

0 comments on commit 81d4f61

Please sign in to comment.