Skip to content

Commit

Permalink
Never auto-save unknown CRSes encountered in the wild
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nyalldawson committed Dec 20, 2019
1 parent cbc1ee5 commit 908684c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
22 changes: 0 additions & 22 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -317,13 +317,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
{
Expand Down Expand Up @@ -769,13 +762,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 );
Expand Down Expand Up @@ -1953,14 +1939,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
{
Expand Down
14 changes: 0 additions & 14 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -3611,29 +3611,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;
Expand Down

0 comments on commit 908684c

Please sign in to comment.