Skip to content
Permalink
Browse files

use unique_ptr to handle provider pointer deletion

  • Loading branch information
troopa81 authored and nyalldawson committed Feb 19, 2021
1 parent 669cead commit 9b6c0ddbae570c4a58f424a8aa1cde4efbc57df0
Showing with 1 addition and 12 deletions.
  1. +1 −12 src/providers/oracle/qgsoracleprovider.cpp
@@ -3098,12 +3098,10 @@ QgsVectorLayerExporter::ExportError QgsOracleProvider::createEmptyLayer(
dsUri.setDataSource( ownerName, tableName, geometryColumn, QString(), primaryKey );

QgsDataProvider::ProviderOptions providerOptions;
QgsOracleProvider *provider = new QgsOracleProvider( dsUri.uri( false ), providerOptions );
std::unique_ptr<QgsOracleProvider> provider( new QgsOracleProvider( dsUri.uri( false ), providerOptions ) );
if ( !provider->isValid() )
{
errorMessage = QObject::tr( "Loading of the layer %1 failed" ).arg( ownerTableName );

delete provider;
return QgsVectorLayerExporter::ErrInvalidLayer;
}

@@ -3143,8 +3141,6 @@ QgsVectorLayerExporter::ExportError QgsOracleProvider::createEmptyLayer(
if ( j == 3 )
{
errorMessage = QObject::tr( "Field name clash found (%1 not remappable)" ).arg( fld.name() );

delete provider;
return QgsVectorLayerExporter::ErrAttributeTypeUnsupported;
}
}
@@ -3178,8 +3174,6 @@ QgsVectorLayerExporter::ExportError QgsOracleProvider::createEmptyLayer(
if ( !( options && options->value( QStringLiteral( "skipConvertFields" ), false ).toBool() ) && ! convertField( fld ) )
{
errorMessage = QObject::tr( "Unsupported type for field %1" ).arg( fld.name() );

delete provider;
return QgsVectorLayerExporter::ErrAttributeTypeUnsupported;
}

@@ -3195,8 +3189,6 @@ QgsVectorLayerExporter::ExportError QgsOracleProvider::createEmptyLayer(
if ( !provider->addAttributes( flist ) )
{
errorMessage = QObject::tr( "Creation of fields failed" );

delete provider;
return QgsVectorLayerExporter::ErrAttributeCreationFailed;
}

@@ -3211,12 +3203,9 @@ QgsVectorLayerExporter::ExportError QgsOracleProvider::createEmptyLayer(
&& !provider->deleteAttributes( QgsAttributeIds { provider->fields().indexOf( fakeColumn ) } ) )
{
errorMessage = QObject::tr( "Remove of temporary column '%1' failed" ).arg( fakeColumn );
delete provider;
return QgsVectorLayerExporter::ErrAttributeCreationFailed;
}

delete provider;

return QgsVectorLayerExporter::NoError;
}

0 comments on commit 9b6c0dd

Please sign in to comment.