Skip to content

Commit

Permalink
Fix cannot deletete GPKG from raster on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Sep 20, 2018
1 parent 5ec3d5d commit e62c4eb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/providers/ogr/qgsgeopackagedataitems.cpp
Expand Up @@ -32,6 +32,7 @@
#include "qgsvectorlayerexporter.h"
#include "qgsgeopackagerasterwritertask.h"
#include "qgstaskmanager.h"
#include "qgsproviderregistry.h"

#include <QAction>
#include <QMessageBox>
Expand Down Expand Up @@ -357,15 +358,16 @@ bool QgsGeoPackageCollectionItem::deleteGeoPackageRasterLayer( const QString &ur
// Better safe than sorry
if ( ! uri.isEmpty( ) )
{
QStringList pieces( uri.split( ':' ) );
if ( pieces.size() != 3 )
QVariantMap pieces( QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "gdal" ), uri ) );
QString baseUri = pieces[QStringLiteral( "path" )].toString();
QString layerName = pieces[QStringLiteral( "layerName" )].toString();

if ( baseUri.isEmpty() || layerName.isEmpty() )
{
errCause = QStringLiteral( "Layer URI is malformed: layer <b>%1</b> cannot be deleted!" ).arg( uri );
}
else
{
QString baseUri = pieces.at( 1 );
QString layerName = pieces.at( 2 );
sqlite3_database_unique_ptr database;
int status = database.open_v2( baseUri, SQLITE_OPEN_READWRITE, nullptr );
if ( status != SQLITE_OK )
Expand Down

0 comments on commit e62c4eb

Please sign in to comment.