From a3ebe6a855ef4a1ce9102a9f50a855e77646c75b Mon Sep 17 00:00:00 2001 From: nirvn Date: Thu, 29 Aug 2019 11:54:01 +0700 Subject: [PATCH] [postgresql] Fix crash when testing a connection fails --- src/providers/postgres/qgspgnewconnection.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/providers/postgres/qgspgnewconnection.cpp b/src/providers/postgres/qgspgnewconnection.cpp index e5913b91e2c..d787e816331 100644 --- a/src/providers/postgres/qgspgnewconnection.cpp +++ b/src/providers/postgres/qgspgnewconnection.cpp @@ -206,19 +206,19 @@ void QgsPgNewConnection::testConnection() QgsPostgresConn *conn = QgsPostgresConn::connectDb( uri.connectionInfo( false ), true ); - if ( conn->pgVersion() < 90500 ) - { - cb_projectsInDatabase->setEnabled( false ); - cb_projectsInDatabase->setToolTip( tr( "Saving projects in databases not available for PostgreSQL databases earlier than 9.5" ) ); - } - else - { - cb_projectsInDatabase->setEnabled( true ); - cb_projectsInDatabase->setToolTip( QString() ); - } - if ( conn ) { + if ( conn->pgVersion() < 90500 ) + { + cb_projectsInDatabase->setEnabled( false ); + cb_projectsInDatabase->setToolTip( tr( "Saving projects in databases not available for PostgreSQL databases earlier than 9.5" ) ); + } + else + { + cb_projectsInDatabase->setEnabled( true ); + cb_projectsInDatabase->setToolTip( QString() ); + } + // Database successfully opened; we can now issue SQL commands. bar->pushMessage( tr( "Connection to %1 was successful." ).arg( txtName->text() ), Qgis::Info );