Skip to content

Commit

Permalink
in import vector layer fix overwrite option and report provider errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brushtyler committed Apr 15, 2012
1 parent 30fb05a commit f8d5d43
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/core/qgsvectorlayerimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,14 @@ bool QgsVectorLayerImport::flushBuffer()

if ( !mProvider->addFeatures( mFeatureBuffer ) )
{
mErrorMessage = QObject::tr( "Creation error for features from #%1 to #%2" )
QStringList errors = mProvider->errors();
mProvider->clearErrors();

mErrorMessage = QObject::tr( "Creation error for features from #%1 to #%2. Provider errors was: \n%3" )
.arg( mFeatureBuffer.first().id() )
.arg( mFeatureBuffer.last().id() );
.arg( mFeatureBuffer.last().id() )
.arg( errors.join( "\n" ) );

mError = ErrFeatureWriteFailed;
mErrorCount += mFeatureBuffer.count();

Expand Down Expand Up @@ -210,8 +215,10 @@ QgsVectorLayerImport::importLayer( QgsVectorLayer* layer,
}
}

bool overwrite = options->take( "overwrite" ).toBool();

QgsVectorLayerImport * writer =
new QgsVectorLayerImport( uri, providerKey, fields, layer->wkbType(), outputCRS, false, options );
new QgsVectorLayerImport( uri, providerKey, fields, layer->wkbType(), outputCRS, overwrite, options );

// check whether file creation was successful
ImportError err = writer->hasError();
Expand Down

0 comments on commit f8d5d43

Please sign in to comment.