Skip to content
Permalink
Browse files

Windows GPKG project storage: fix path encoding

... in a particular sequence of connection creation,
fixes #36832

(cherry picked from commit 2d3c36f)
  • Loading branch information
elpaso authored and nyalldawson committed Jul 21, 2020
1 parent 3c96070 commit 7ebb3f54a9d2d4b3c7c55d06f205a894140d3583
@@ -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() )
@@ -349,7 +349,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 );
@@ -367,7 +367,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() )
@@ -395,7 +395,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 7ebb3f5

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