Skip to content

Commit

Permalink
Invalidate crs cache after adding a new user CRS
Browse files Browse the repository at this point in the history
Refs #17257
  • Loading branch information
nyalldawson committed Nov 13, 2017
1 parent e0b2c27 commit 39851f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -1714,6 +1714,8 @@ long QgsCoordinateReferenceSystem::saveAsUserCrs( const QString &name )
}
else
returnId = -1;

invalidateCache();
return returnId;
}

Expand Down
8 changes: 8 additions & 0 deletions tests/src/core/testqgscoordinatereferencesystem.cpp
Expand Up @@ -106,6 +106,7 @@ void TestQgsCoordinateReferenceSystem::initTestCase()
//
// init QGIS's paths - true means that all path will be inited from prefix
QgsApplication::init( mTempFolder );
QgsApplication::createDatabase();
QgsApplication::initQgis();
QgsApplication::showSettings();

Expand Down Expand Up @@ -820,6 +821,13 @@ void TestQgsCoordinateReferenceSystem::saveAsUserCrs()

long newId = userCrs.saveAsUserCrs( QStringLiteral( "babies first projection" ) );
QCOMPARE( newId, static_cast< long >( USER_CRS_START_ID ) );
QCOMPARE( userCrs.srsid(), newId );

// new CRS with same definition, check that it's matched to user crs
QgsCoordinateReferenceSystem userCrs2 = QgsCoordinateReferenceSystem::fromProj4( madeUpProjection );
QVERIFY( userCrs2.isValid() );
QCOMPARE( userCrs2.toProj4(), madeUpProjection );
QCOMPARE( userCrs2.srsid(), userCrs.srsid() );
}

QGSTEST_MAIN( TestQgsCoordinateReferenceSystem )
Expand Down

0 comments on commit 39851f4

Please sign in to comment.