Skip to content

Commit b54e837

Browse files
committed
fix #5481
1 parent c10b040 commit b54e837

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/gui/qgsnewvectorlayerdialog.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ QString QgsNewVectorLayerDialog::runAndCreateLayer( QWidget* parent, QString* pE
286286
if ( geometrytype != QGis::WKBUnknown )
287287
{
288288
QgsCoordinateReferenceSystem srs( crsId, QgsCoordinateReferenceSystem::InternalCrsId );
289-
createEmptyDataSource( fileName, fileformat, enc, geometrytype, attributes, &srs );
289+
if ( !createEmptyDataSource( fileName, fileformat, enc, geometrytype, attributes, &srs ) )
290+
{
291+
return QString();
292+
}
290293
}
291294
else
292295
{

src/providers/ogr/qgsogrprovider.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
19431943
{
19441944
if ( !uri.endsWith( ".shp", Qt::CaseInsensitive ) )
19451945
{
1946+
QgsDebugMsg( QString( "uri %1 doesn't end with .shp" ).arg( uri ) );
19461947
return false;
19471948
}
19481949

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

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

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

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

0 commit comments

Comments
 (0)