Skip to content

Commit

Permalink
pass password on to geometry type detection thread
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12795 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jan 19, 2010
1 parent d49dc34 commit 9cc24e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/app/postgres/qgspgsourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ QString QgsPgSourceSelect::layerURI( const QModelIndex &index )
}
}

QString uri = m_connectionInfo;
QString uri = m_connInfo;

if ( !pkColumnName.isEmpty() )
{
Expand Down Expand Up @@ -400,13 +400,15 @@ void QgsPgSourceSelect::on_btnConnect_clicked()

QgsDebugMsg( "Connection info: " + uri.connectionInfo() );

m_connectionInfo = uri.connectionInfo();
//qDebug(m_connectionInfo);
m_connInfo = uri.connectionInfo();

// Tidy up an existing connection if one exists.
if ( pd != 0 )
PQfinish( pd );

pd = PQconnectdb( uri.connectionInfo().toLocal8Bit() ); // use what is set based on locale; after connecting, use Utf8
m_privConnInfo = m_connInfo;

pd = PQconnectdb( m_privConnInfo.toLocal8Bit() ); // use what is set based on locale; after connecting, use Utf8
// check the connection status
if ( PQstatus( pd ) != CONNECTION_OK && QString::fromUtf8( PQerrorMessage( pd ) ) == PQnoPasswordSupplied )
{
Expand All @@ -419,7 +421,7 @@ void QgsPgSourceSelect::on_btnConnect_clicked()
tr( "Enter password" ),
tr( "Error: %1Enter password for %2" )
.arg( QString::fromUtf8( PQerrorMessage( pd ) ) )
.arg( uri.connectionInfo() ),
.arg( m_connInfo ),
QLineEdit::Password,
password,
&ok );
Expand All @@ -429,7 +431,8 @@ void QgsPgSourceSelect::on_btnConnect_clicked()
if ( !ok )
break;

pd = PQconnectdb( QString( "%1 password='%2'" ).arg( uri.connectionInfo() ).arg( password ).toLocal8Bit() );
m_privConnInfo = QString( "%1 password='%2'" ).arg( m_connInfo ).arg( password );
pd = PQconnectdb( m_privConnInfo.toLocal8Bit() );
}
}

Expand Down Expand Up @@ -497,7 +500,7 @@ QStringList QgsPgSourceSelect::selectedTables()

QString QgsPgSourceSelect::connectionInfo()
{
return m_connectionInfo;
return m_connInfo;
}

void QgsPgSourceSelect::setSql( const QModelIndex &index )
Expand Down Expand Up @@ -533,7 +536,7 @@ void QgsPgSourceSelect::addSearchGeometryColumn( const QString &schema, const QS
if ( mColumnTypeThread == NULL )
{
mColumnTypeThread = new QgsGeomColumnTypeThread();
mColumnTypeThread->setConnInfo( m_connectionInfo );
mColumnTypeThread->setConnInfo( m_privConnInfo );
}
mColumnTypeThread->addGeometryColumn( schema, table, column );
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/postgres/qgspgsourceselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ class QgsPgSourceSelect : public QDialog, private Ui::QgsPgSourceSelectBase
QStringList mColumnLabels;
// Our thread for doing long running queries
QgsGeomColumnTypeThread* mColumnTypeThread;
QString m_connectionInfo;
QString m_connInfo;
QString m_privConnInfo;
QStringList m_selectedTables;
// Storage for the range of layer type icons
QMap<QString, QPair<QString, QIcon> > mLayerIcons;
Expand Down

0 comments on commit 9cc24e2

Please sign in to comment.