diff options
-rw-r--r-- | src/plugins/sqldrivers/psql/qsql_psql.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index e928f02ff4..b6b2174a01 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1197,8 +1197,7 @@ bool QPSQLDriver::open(const QString &db, const QString &connOpts) { Q_D(QPSQLDriver); - if (isOpen()) - close(); + close(); QString connectString; if (!host.isEmpty()) connectString.append(QLatin1String("host=")).append(qQuote(host)); @@ -1241,21 +1240,19 @@ bool QPSQLDriver::open(const QString &db, void QPSQLDriver::close() { Q_D(QPSQLDriver); - if (isOpen()) { - d->seid.clear(); - if (d->sn) { - disconnect(d->sn, SIGNAL(activated(QSocketDescriptor)), this, SLOT(_q_handleNotification())); - delete d->sn; - d->sn = nullptr; - } - - if (d->connection) - PQfinish(d->connection); - d->connection = nullptr; - setOpen(false); - setOpenError(false); + d->seid.clear(); + if (d->sn) { + disconnect(d->sn, SIGNAL(activated(QSocketDescriptor)), this, SLOT(_q_handleNotification())); + delete d->sn; + d->sn = nullptr; } + + if (d->connection) + PQfinish(d->connection); + d->connection = nullptr; + setOpen(false); + setOpenError(false); } QSqlResult *QPSQLDriver::createResult() const |