mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-23 00:02:38 -05:00
* Fix #38473, forgetting CRS in a new project
This commit is contained in:
parent
9d7b550169
commit
51d7044050
@ -730,6 +730,7 @@ void QgsProject::clear()
|
||||
mDirty = false;
|
||||
mTrustLayerMetadata = false;
|
||||
mCustomVariables.clear();
|
||||
mCrs = QgsCoordinateReferenceSystem();
|
||||
mMetadata = QgsProjectMetadata();
|
||||
if ( !settings.value( QStringLiteral( "projects/anonymize_new_projects" ), false, QgsSettings::Core ).toBool() )
|
||||
{
|
||||
|
@ -48,6 +48,7 @@ class TestQgsProject : public QObject
|
||||
void testReadFlags();
|
||||
void testSetGetCrs();
|
||||
void testEmbeddedLayerGroupFromQgz();
|
||||
void testCrsValidAfterReadingProjectFile();
|
||||
};
|
||||
|
||||
void TestQgsProject::init()
|
||||
@ -568,9 +569,38 @@ void TestQgsProject::testSetGetCrs()
|
||||
#else
|
||||
QCOMPARE( p.ellipsoid(), QStringLiteral( "bessel" ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
crsChangedSpy.clear();
|
||||
ellipsoidChangedSpy.clear();
|
||||
void TestQgsProject::testCrsValidAfterReadingProjectFile()
|
||||
{
|
||||
QgsProject p;
|
||||
QSignalSpy crsChangedSpy( &p, &QgsProject::crsChanged );
|
||||
|
||||
// - new project
|
||||
// - set CRS tp 4326, the crs changes
|
||||
// - save the project
|
||||
// - clear()
|
||||
// - load the project, the CRS should be 4326
|
||||
QTemporaryDir dir;
|
||||
QVERIFY( dir.isValid() );
|
||||
// on mac the returned path was not canonical and the resolver failed to convert paths properly
|
||||
QString dirPath = QFileInfo( dir.path() ).canonicalFilePath();
|
||||
QString projectFilename = dirPath + "/project.qgs";
|
||||
|
||||
p.setCrs( QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) );
|
||||
|
||||
QCOMPARE( crsChangedSpy.count(), 1 );
|
||||
QCOMPARE( p.crs(), QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) );
|
||||
|
||||
QVERIFY( p.write( projectFilename ) );
|
||||
p.clear();
|
||||
|
||||
QCOMPARE( p.crs(), QgsCoordinateReferenceSystem() );
|
||||
QCOMPARE( crsChangedSpy.count(), 1 );
|
||||
|
||||
QVERIFY( p.read( projectFilename ) );
|
||||
QCOMPARE( p.crs(), QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) );
|
||||
QCOMPARE( crsChangedSpy.count(), 2 );
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user