Skip to content
Permalink
Browse files

Windows GPKG project storage: fix path encoding

... in a particular sequence of connection creation,
fixes #36832
  • Loading branch information
elpaso committed Jun 4, 2020
1 parent 739f4de commit 2d3c36f3d7f6b40ff75d1a991deb4262ef99a95c
@@ -219,7 +219,7 @@ bool QgsGeoPackageProjectStorage::writeProject( const QString &uri, QIODevice *d

if ( errCause.isEmpty() && !_projectsTableExists( projectUri.database ) )
{
errCause = _executeSql( uri, QStringLiteral( "CREATE TABLE qgis_projects(name TEXT PRIMARY KEY, metadata BLOB, content BLOB)" ) );
errCause = _executeSql( projectUri.database, QStringLiteral( "CREATE TABLE qgis_projects(name TEXT PRIMARY KEY, metadata BLOB, content BLOB)" ) );
}

if ( !errCause.isEmpty() )
@@ -356,7 +356,7 @@ QString QgsGeoPackageProjectStorage::_executeSql( const QString &uri, const QStr
bool QgsGeoPackageProjectStorage::removeProject( const QString &uri )
{
QgsGeoPackageProjectUri projectUri = decodeUri( uri );
QString errCause = _executeSql( uri, QStringLiteral( "DELETE FROM qgis_projects WHERE name = %1" ).arg( QgsSqliteUtils::quotedValue( projectUri.projectName ) ) );
QString errCause = _executeSql( projectUri.database, QStringLiteral( "DELETE FROM qgis_projects WHERE name = %1" ).arg( QgsSqliteUtils::quotedValue( projectUri.projectName ) ) );
if ( ! errCause.isEmpty() )
{
errCause = QObject::tr( "Could not remove project %1: %2" ).arg( uri, errCause );
@@ -374,7 +374,7 @@ bool QgsGeoPackageProjectStorage::renameProject( const QString &uri, const QStri
{
QgsGeoPackageProjectUri projectNewUri = decodeUri( uriNew );
QgsGeoPackageProjectUri projectUri = decodeUri( uri );
QString errCause = _executeSql( uri, QStringLiteral( "UPDATE qgis_projects SET name = %1 WHERE name = %1" )
QString errCause = _executeSql( projectUri.database, QStringLiteral( "UPDATE qgis_projects SET name = %1 WHERE name = %1" )
.arg( QgsSqliteUtils::quotedValue( projectUri.projectName ) )
.arg( QgsSqliteUtils::quotedValue( projectNewUri.projectName ) ) );
if ( ! errCause.isEmpty() )
@@ -394,7 +394,8 @@ void QgsGeoPackageItemGuiProvider::createDatabase()
dialog.setCrs( QgsProject::instance()->defaultCrsForNewLayers() );
if ( dialog.exec() == QDialog::Accepted )
{
if ( QgsOgrDataCollectionItem::saveConnection( dialog.databasePath(), QStringLiteral( "GPKG" ) ) )
// Call QFileInfo to normalize paths, see: https://github.com/qgis/QGIS/issues/36832
if ( QgsOgrDataCollectionItem::saveConnection( QFileInfo( dialog.databasePath() ).filePath(), QStringLiteral( "GPKG" ) ) )
{
item->refreshConnections();
}

0 comments on commit 2d3c36f

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