Skip to content

Commit e62c4eb

Browse files
committed
Fix cannot deletete GPKG from raster on windows
Fixes #17967 #19893
1 parent 5ec3d5d commit e62c4eb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/providers/ogr/qgsgeopackagedataitems.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "qgsvectorlayerexporter.h"
3333
#include "qgsgeopackagerasterwritertask.h"
3434
#include "qgstaskmanager.h"
35+
#include "qgsproviderregistry.h"
3536

3637
#include <QAction>
3738
#include <QMessageBox>
@@ -357,15 +358,16 @@ bool QgsGeoPackageCollectionItem::deleteGeoPackageRasterLayer( const QString &ur
357358
// Better safe than sorry
358359
if ( ! uri.isEmpty( ) )
359360
{
360-
QStringList pieces( uri.split( ':' ) );
361-
if ( pieces.size() != 3 )
361+
QVariantMap pieces( QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "gdal" ), uri ) );
362+
QString baseUri = pieces[QStringLiteral( "path" )].toString();
363+
QString layerName = pieces[QStringLiteral( "layerName" )].toString();
364+
365+
if ( baseUri.isEmpty() || layerName.isEmpty() )
362366
{
363367
errCause = QStringLiteral( "Layer URI is malformed: layer <b>%1</b> cannot be deleted!" ).arg( uri );
364368
}
365369
else
366370
{
367-
QString baseUri = pieces.at( 1 );
368-
QString layerName = pieces.at( 2 );
369371
sqlite3_database_unique_ptr database;
370372
int status = database.open_v2( baseUri, SQLITE_OPEN_READWRITE, nullptr );
371373
if ( status != SQLITE_OK )

0 commit comments

Comments
 (0)