@@ -1099,16 +1099,18 @@ void QgsCoordinateReferenceSystem::setProj4String( const QString &proj4String )
1099
1099
// e.g if they lack a +ellps parameter, it will automatically add +ellps=WGS84, but as
1100
1100
// we use the original mProj4 with QgsCoordinateTransform, it will fail to initialize
1101
1101
// so better detect it now.
1102
- projPJ proj = pj_init_plus ( proj4String.trimmed ().toLatin1 ().constData () );
1102
+ projCtx pContext = pj_ctx_alloc ();
1103
+ projPJ proj = pj_init_plus_ctx ( pContext, proj4String.trimmed ().toLatin1 ().constData () );
1103
1104
if ( !proj )
1104
1105
{
1105
- QgsDebugMsgLevel ( " proj.4 string rejected by pj_init_plus ()" , 4 );
1106
+ QgsDebugMsgLevel ( " proj.4 string rejected by pj_init_plus_ctx ()" , 4 );
1106
1107
d->mIsValid = false ;
1107
1108
}
1108
1109
else
1109
1110
{
1110
1111
pj_free ( proj );
1111
1112
}
1113
+ pj_ctx_free ( pContext );
1112
1114
d->mWkt .clear ();
1113
1115
setMapUnits ();
1114
1116
}
@@ -2020,6 +2022,8 @@ int QgsCoordinateReferenceSystem::syncDatabase()
2020
2022
sqlite3_errmsg ( database ) );
2021
2023
}
2022
2024
2025
+ projCtx pContext = pj_ctx_alloc ();
2026
+
2023
2027
#if !defined(PJ_VERSION) || PJ_VERSION!=470
2024
2028
sql = QStringLiteral ( " select auth_name,auth_id,parameters from tbl_srs WHERE auth_name<>'EPSG' AND NOT deprecated AND NOT noupdate" );
2025
2029
if ( sqlite3_prepare ( database, sql.toLatin1 (), sql.size (), &select , &tail ) == SQLITE_OK )
@@ -2031,11 +2035,11 @@ int QgsCoordinateReferenceSystem::syncDatabase()
2031
2035
const char *params = reinterpret_cast < const char * >( sqlite3_column_text ( select , 2 ) );
2032
2036
2033
2037
QString input = QStringLiteral ( " +init=%1:%2" ).arg ( QString ( auth_name ).toLower (), auth_id );
2034
- projPJ pj = pj_init_plus ( input.toLatin1 () );
2038
+ projPJ pj = pj_init_plus_ctx ( pContext, input.toLatin1 () );
2035
2039
if ( !pj )
2036
2040
{
2037
2041
input = QStringLiteral ( " +init=%1:%2" ).arg ( QString ( auth_name ).toUpper (), auth_id );
2038
- pj = pj_init_plus ( input.toLatin1 () );
2042
+ pj = pj_init_plus_ctx ( pContext, input.toLatin1 () );
2039
2043
}
2040
2044
2041
2045
if ( pj )
@@ -2099,6 +2103,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()
2099
2103
sqlite3_finalize ( select );
2100
2104
#endif
2101
2105
2106
+ pj_ctx_free ( pContext );
2102
2107
2103
2108
if ( sqlite3_exec ( database, " COMMIT" , nullptr , nullptr , nullptr ) != SQLITE_OK )
2104
2109
{
0 commit comments