Skip to content

Commit

Permalink
Fix crash with invalid postgres provider
Browse files Browse the repository at this point in the history
Crash is triggered by opening the postgres vector layer properties with a not-yet-known CRS.
  • Loading branch information
m-kuhn authored and nyalldawson committed Oct 30, 2019
1 parent 28bd757 commit 95fb8e6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -4272,11 +4272,14 @@ QgsCoordinateReferenceSystem QgsPostgresProvider::crs() const
else
{
QgsPostgresConn *conn = connectionRO();
QgsPostgresResult result( conn->PQexec( QStringLiteral( "SELECT proj4text FROM spatial_ref_sys WHERE srid=%1" ).arg( srid ) ) );
if ( result.PQresultStatus() == PGRES_TUPLES_OK )
if ( conn )
{
srs = QgsCoordinateReferenceSystem::fromProj4( result.PQgetvalue( 0, 0 ) );
sCrsCache.insert( srid, srs );
QgsPostgresResult result( conn->PQexec( QStringLiteral( "SELECT proj4text FROM spatial_ref_sys WHERE srid=%1" ).arg( srid ) ) );
if ( result.PQresultStatus() == PGRES_TUPLES_OK )
{
srs = QgsCoordinateReferenceSystem::fromProj4( result.PQgetvalue( 0, 0 ) );
sCrsCache.insert( srid, srs );
}
}
}
}
Expand Down

0 comments on commit 95fb8e6

Please sign in to comment.