Skip to content

Commit

Permalink
Fix: HANA layer is empty when importing from 'memory' VectorLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
mrylov authored and nyalldawson committed May 17, 2021
1 parent 8e4de4b commit d94b60a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/providers/hana/qgshanadataitems.cpp
Expand Up @@ -152,7 +152,15 @@ bool QgsHanaConnectionItem::handleDrop( const QMimeData *data, const QString &to
}

// open the source layer
QgsVectorLayer *srcLayer = new QgsVectorLayer( u.uri, u.name, u.providerKey );
bool owner;
QString error;
QgsVectorLayer *srcLayer = u.vectorLayer( owner, error );
if ( !srcLayer )
{
importResults.append( tr( "%1: %2" ).arg( u.name, error ) );
hasError = true;
continue;
}

if ( srcLayer->isValid() )
{
Expand All @@ -168,8 +176,9 @@ bool QgsHanaConnectionItem::handleDrop( const QMimeData *data, const QString &to
uri.setWkbType( srcLayer->wkbType() );

std::unique_ptr< QgsVectorLayerExporterTask > exportTask(
QgsVectorLayerExporterTask::withLayerOwnership( srcLayer, uri.uri( false ),
QStringLiteral( "hana" ), srcLayer->crs() ) );
new QgsVectorLayerExporterTask( srcLayer, uri.uri( false ),
QStringLiteral( "hana" ), srcLayer->crs(), QVariantMap(), owner ) );

// when export is successful:
connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, this,
[ = ]()
Expand Down

0 comments on commit d94b60a

Please sign in to comment.