Skip to content

Commit e49b07c

Browse files
committedMay 24, 2019
Never try to create a crs from an empty proj string, just shortcut and mark as invalid instead
Avoids proj warnings
1 parent e8a74f4 commit e49b07c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
 

‎src/core/qgscoordinatereferencesystem.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,14 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
796796
{
797797
d.detach();
798798

799+
if ( proj4String.trimmed().isEmpty() )
800+
{
801+
d->mIsValid = false;
802+
d->mWkt.clear();
803+
d->mProj4.clear();
804+
return false;
805+
}
806+
799807
sProj4CacheLock.lockForRead();
800808
QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = sProj4Cache.constFind( proj4String );
801809
if ( crsIt != sProj4Cache.constEnd() )

‎tests/src/core/testqgscoordinatereferencesystem.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,9 @@ void TestQgsCoordinateReferenceSystem::srsIdCache()
509509
void TestQgsCoordinateReferenceSystem::createFromProj4()
510510
{
511511
QgsCoordinateReferenceSystem myCrs;
512+
QVERIFY( !myCrs.createFromProj4( QString() ) );
513+
QVERIFY( !myCrs.isValid() );
514+
512515
QVERIFY( myCrs.createFromProj4( GEOPROJ4 ) );
513516
debugPrint( myCrs );
514517
QVERIFY( myCrs.isValid() );

0 commit comments

Comments
 (0)
Please sign in to comment.