Skip to content
Permalink
Browse files
handle broken postgis installations more traceful
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10578 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 16, 2009
1 parent fdc93dc commit dd0f5c9df7f61a8a3062604b9128b25a653bd393
Showing with 22 additions and 0 deletions.
  1. +22 −0 src/providers/postgres/qgspostgresprovider.cpp
@@ -310,6 +310,17 @@ QgsPostgresProvider::Conn *QgsPostgresProvider::Conn::connectDb( const QString &
QgsDebugMsg( "Connection to the database was successful" );

Conn *conn = new Conn( pd );

/* Check to see if we have working PostGIS support */
if ( conn->postgisVersion().isNull() )
{
showMessageBox( tr( "No PostGIS Support!" ),
tr( "Your database has no working PostGIS support.\n") );
conn->PQfinish();
delete conn;
return NULL;
}

connections.insert( conninfo, conn );

/* Check to see if we have GEOS support and if not, warn the user about
@@ -1732,6 +1743,12 @@ bool QgsPostgresProvider::Conn::hasGEOS()
QString QgsPostgresProvider::Conn::postgisVersion()
{
Result result = PQexec( "select postgis_version()" );
if( PQntuples( result ) != 1 )
{
QgsDebugMsg( "Retrieval of postgis version failed" );
return QString::null;
}

postgisVersionInfo = QString::fromUtf8( PQgetvalue( result, 0, 0 ) );

QgsDebugMsg( "PostGIS version info: " + postgisVersionInfo );
@@ -1740,6 +1757,11 @@ QString QgsPostgresProvider::Conn::postgisVersion()

// Get major and minor version
QStringList postgisVersionParts = postgisParts[0].split( ".", QString::SkipEmptyParts );
if( postgisVersionParts.size() < 2 )
{
QgsDebugMsg( "Could not parse postgis version" );
return QString::null;
}

postgisVersionMajor = postgisVersionParts[0].toInt();
postgisVersionMinor = postgisVersionParts[1].toInt();

0 comments on commit dd0f5c9

Please sign in to comment.