Skip to content

Commit

Permalink
fix #5481
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Apr 24, 2012
1 parent c10b040 commit b54e837
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/gui/qgsnewvectorlayerdialog.cpp
Expand Up @@ -286,7 +286,10 @@ QString QgsNewVectorLayerDialog::runAndCreateLayer( QWidget* parent, QString* pE
if ( geometrytype != QGis::WKBUnknown )
{
QgsCoordinateReferenceSystem srs( crsId, QgsCoordinateReferenceSystem::InternalCrsId );
createEmptyDataSource( fileName, fileformat, enc, geometrytype, attributes, &srs );
if ( !createEmptyDataSource( fileName, fileformat, enc, geometrytype, attributes, &srs ) )
{
return QString();
}
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -1943,6 +1943,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
{
if ( !uri.endsWith( ".shp", Qt::CaseInsensitive ) )
{
QgsDebugMsg( QString( "uri %1 doesn't end with .shp" ).arg( uri ) );
return false;
}

Expand Down Expand Up @@ -1971,6 +1972,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
dataSource = OGR_Dr_CreateDataSource( driver, TO8F( uri ), NULL );
if ( !dataSource )
{
QgsMessageLog::logMessage( QObject::tr( "Creating the data source %1 failed: %2" ).arg( uri ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ), QObject::tr( "OGR" ) );
return false;
}

Expand Down Expand Up @@ -2028,6 +2030,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
layer = OGR_DS_CreateLayer( dataSource, TO8F( QFileInfo( uri ).completeBaseName() ), reference, OGRvectortype, NULL );
if ( !layer )
{
QgsMessageLog::logMessage( QObject::tr( "Creation of OGR data source %1 failed: %2" ).arg( uri ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ), QObject::tr( "OGR" ) );
return false;
}

Expand All @@ -2041,7 +2044,6 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
Q_ASSERT( codec );
}


for ( std::list<std::pair<QString, QString> >::const_iterator it = attributes.begin(); it != attributes.end(); ++it )
{
QStringList fields = it->second.split( ";" );
Expand Down

0 comments on commit b54e837

Please sign in to comment.