Skip to content
Permalink
Browse files

Guard for options null

  • Loading branch information
elpaso committed Jul 16, 2020
1 parent 9d30cd7 commit 9d1d88d2072724b080f840ed41e89a3541882cac
@@ -1839,7 +1839,7 @@ QgsVectorLayerExporter::ExportError QgsMssqlProvider::createEmptyLayer( const QS
{
// found, get the field type
QgsField fld = fields.at( i );
if ( options->value( QStringLiteral( "skipConvertFields" ), false ).toBool() || convertField( fld ) )
if ( (options && options->value( QStringLiteral( "skipConvertFields" ), false ).toBool()) || convertField( fld ) )
{
primaryKeyType = fld.typeName();
}
@@ -2019,7 +2019,7 @@ QgsVectorLayerExporter::ExportError QgsMssqlProvider::createEmptyLayer( const QS
continue;
}

if ( !options->value( QStringLiteral( "skipConvertFields" ), false ).toBool() && !convertField( fld ) )
if ( ! (options && options->value( QStringLiteral( "skipConvertFields" ), false ).toBool()) && !convertField( fld ) )
{
if ( errorMessage )
*errorMessage = QObject::tr( "Unsupported type for field %1" ).arg( fld.name() );
@@ -2990,7 +2990,7 @@ QgsVectorLayerExporter::ExportError QgsOracleProvider::createEmptyLayer(
if ( idx >= 0 )
{
QgsField fld = fields.at( idx );
if ( options->value( QStringLiteral( "skipConvertFields" ), false ).toBool() || convertField( fld ) )
if ( (options && options->value( QStringLiteral( "skipConvertFields" ), false ).toBool()) || convertField( fld ) )
{
primaryKeyType = fld.typeName();
}
@@ -3243,7 +3243,7 @@ QgsVectorLayerExporter::ExportError QgsOracleProvider::createEmptyLayer(
continue;
}

if ( ! options->value( QStringLiteral( "skipConvertFields" ), false ).toBool() && ! convertField( fld ) )
if ( ! (options && options->value( QStringLiteral( "skipConvertFields" ), false ).toBool()) && ! convertField( fld ) )
{
errorMessage = QObject::tr( "Unsupported type for field %1" ).arg( fld.name() );

@@ -4447,7 +4447,7 @@ QgsVectorLayerExporter::ExportError QgsPostgresProvider::createEmptyLayer( const
continue;
}

if ( ! options->value( QStringLiteral( "skipConvertFields" ), false ).toBool() && !convertField( fld, options ) )
if ( ! (options && options->value( QStringLiteral( "skipConvertFields" ), false ).toBool()) && !convertField( fld, options ) )
{
if ( errorMessage )
*errorMessage = QObject::tr( "Unsupported type for field %1" ).arg( fld.name() );
@@ -201,7 +201,7 @@ QgsSpatiaLiteProvider::createEmptyLayer( const QString &uri,
{
// found it, get the field type
QgsField fld = fields.at( fldIdx );
if ( options->value( QStringLiteral( "skipConvertFields" ), false ).toBool() || convertField( fld ) )
if ( ( options && options->value( QStringLiteral( "skipConvertFields" ), false ).toBool()) || convertField( fld ) )
{
primaryKeyType = fld.typeName();
}
@@ -416,7 +416,7 @@ QgsSpatiaLiteProvider::createEmptyLayer( const QString &uri,
continue;
}

if ( ! options->value( QStringLiteral( "skipConvertFields" ), false ).toBool() && !convertField( fld ) )
if ( ! ( options && options->value( QStringLiteral( "skipConvertFields" ), false ).toBool()) && !convertField( fld ) )
{
QgsDebugMsg( "error creating field " + fld.name() + ": unsupported type" );
if ( errorMessage )

0 comments on commit 9d1d88d

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