Skip to content

Commit

Permalink
close connection when deleting oracle transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 authored and nyalldawson committed Jan 2, 2020
1 parent 94d0b06 commit 00d0a06
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/providers/oracle/qgsoracleconn.cpp
Expand Up @@ -201,6 +201,7 @@ void QgsOracleConn::reconnect()

void QgsOracleConn::unref()
{
QMutexLocker locker( &mLock );
if ( --mRef > 0 )
return;

Expand All @@ -218,7 +219,9 @@ void QgsOracleConn::unref()
}
}

deleteLater();
// to avoid destroying locked mutex
locker.unlock();
delete this;
}

bool QgsOracleConn::exec( QSqlQuery &qry, const QString &sql, const QVariantList &params )
Expand Down
6 changes: 6 additions & 0 deletions src/providers/oracle/qgsoracletransaction.cpp
Expand Up @@ -29,6 +29,12 @@ QgsOracleTransaction::QgsOracleTransaction( const QString &connString )

}

QgsOracleTransaction::~QgsOracleTransaction()
{
if ( mConn )
mConn->unref();
}

bool QgsOracleTransaction::beginTransaction( QString &, int /* statementTimeout */ )
{
mConn = QgsOracleConn::connectDb( mConnString, true /*transaction*/ );
Expand Down
2 changes: 2 additions & 0 deletions src/providers/oracle/qgsoracletransaction.h
Expand Up @@ -33,6 +33,8 @@ class QgsOracleTransaction : public QgsTransaction
public:
explicit QgsOracleTransaction( const QString &connString );

~QgsOracleTransaction() override;

bool executeSql( const QString &sql, QString &error, bool isDirty = false, const QString &name = QString() ) override;

QgsOracleConn *connection() const { return mConn; }
Expand Down

0 comments on commit 00d0a06

Please sign in to comment.