Skip to content
Permalink
Browse files

Never auto-save unknown CRSes encountered in the wild

Previously whenever an unknown CRS (i.e. something which couldn't
be matched a standard or user crs) was encountered then it would
automatically be saved to the user's custom CRS database.

This meant that over time, the custom CRS database would fill
with dozens of random entries. Even a clean QGIS install would
pollute the custom projection list with a bunch of automatically
created random CRS definitions!

Instead, never auto save CRSes to the custom projection database.
Only projections which users have manually created via the custom
projection dialog should ever be available as User CRSes.

(cherry picked from commit 908684c)
  • Loading branch information
nyalldawson committed Dec 18, 2019
1 parent fc06fce commit e1641cdd09ed3232354a3e5bbc10dffbd10bf703
Showing with 0 additions and 36 deletions.
  1. +0 −22 src/core/qgscoordinatereferencesystem.cpp
  2. +0 −14 src/providers/spatialite/qgsspatialiteprovider.cpp
@@ -314,13 +314,6 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString &definition )
if ( match.captured( 1 ).compare( QLatin1String( "proj4" ), Qt::CaseInsensitive ) == 0 )
{
result = createFromProj( match.captured( 2 ) );
if ( srsid() == 0 )
{
QString myName = QStringLiteral( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ),
toProj() );
saveAsUserCrs( myName );
}
}
else
{
@@ -766,13 +759,6 @@ bool QgsCoordinateReferenceSystem::createFromWkt( const QString &wkt )
else
{
setWktString( wkt );
if ( d->mSrsId == 0 )
{
QString myName = QStringLiteral( " * %1 (%2...)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ),
wkt.left( 50 ) );
saveAsUserCrs( myName );
}
}

locker.changeMode( QgsReadWriteLocker::Write );
@@ -1950,14 +1936,6 @@ bool QgsCoordinateReferenceSystem::readXml( const QDomNode &node )
//make sure the map units have been set
setMapUnits();
}

if ( isValid() && d->mSrsId == 0 )
{
QString myName = QStringLiteral( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ),
toProj() );
saveAsUserCrs( myName );
}
}
else
{
@@ -3609,29 +3609,15 @@ QgsCoordinateReferenceSystem QgsSpatiaLiteProvider::crs() const
if ( !srs.isValid() )
{
srs = QgsCoordinateReferenceSystem::fromProj( mProj4text );
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if ( srs.srsid() == 0 )
{
QString myName = QStringLiteral( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ),
srs.toProj() );
srs.saveAsUserCrs( myName );
}

}
return srs;
}


bool QgsSpatiaLiteProvider::isValid() const
{
return mValid;
}


QString QgsSpatiaLiteProvider::name() const
{
return SPATIALITE_KEY;

0 comments on commit e1641cd

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