diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp index 66e51252317..a6f34758b81 100644 --- a/src/core/qgscoordinatereferencesystem.cpp +++ b/src/core/qgscoordinatereferencesystem.cpp @@ -1244,10 +1244,12 @@ QString QgsCoordinateReferenceSystem::proj4FromSrsId( const int theSrsId ) return myProjString; } -int QgsCoordinateReferenceSystem::openDb( QString path, sqlite3 **db ) +int QgsCoordinateReferenceSystem::openDb( QString path, sqlite3 **db, bool readonly ) { QgsDebugMsgLevel( "path = " + path, 3 ); - int myResult = sqlite3_open( path.toUtf8().data(), db ); + int myResult = readonly + ? sqlite3_open_v2( path.toUtf8().data(), db, SQLITE_OPEN_READONLY, NULL ) + : sqlite3_open( path.toUtf8().data(), db ); if ( myResult != SQLITE_OK ) { diff --git a/src/core/qgscoordinatereferencesystem.h b/src/core/qgscoordinatereferencesystem.h index 91965e1afed..850288a20ad 100644 --- a/src/core/qgscoordinatereferencesystem.h +++ b/src/core/qgscoordinatereferencesystem.h @@ -398,9 +398,9 @@ class CORE_EXPORT QgsCoordinateReferenceSystem */ RecordMap getRecord( QString theSql ); - // Open SQLite db and show message if ccannot be opened + // Open SQLite db and show message if cannot be opened // returns the same code as sqlite3_open - static int openDb( QString path, sqlite3 **db ); + static int openDb( QString path, sqlite3 **db, bool readonly = true ); //!The internal sqlite3 srs.db primary key for this srs long mSrsId;