Skip to content

Commit

Permalink
Tighten scope of connection
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 1, 2018
1 parent a5ff6db commit c782f27
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/auth/qgsauthmanager.cpp
Expand Up @@ -140,7 +140,7 @@ QSqlDatabase QgsAuthManager::authDatabaseConnection() const
// triggers a condition in QSqlDatabase which detects the nullptr private thread data and returns an invalid database instead.
// QSqlDatabase::removeDatabase is thread safe, so this is ok to do.
// Right about now is a good time to re-evaluate your selected career ;)
connect( QThread::currentThread(), &QThread::finished, this, [connectionName, this ]
connect( QThread::currentThread(), &QThread::finished, QThread::currentThread(), [connectionName, this ]
{
QMutexLocker locker( mMutex );
QgsDebugMsgLevel( QStringLiteral( "Removing outdated connection to %1 on thread exit" ).arg( connectionName ), 2 );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlconnection.cpp
Expand Up @@ -73,7 +73,7 @@ QSqlDatabase QgsMssqlConnection::getDatabase( const QString &service, const QStr
// and a subsequent call to QSqlDatabase::database with the same thread address (yep it happens, actually a lot)
// triggers a condition in QSqlDatabase which detects the nullptr private thread data and returns an invalid database instead.
// QSqlDatabase::removeDatabase is thread safe, so this is ok to do.
QObject::connect( QThread::currentThread(), &QThread::finished, QCoreApplication::instance(), [connectionName]
QObject::connect( QThread::currentThread(), &QThread::finished, QThread::currentThread(), [connectionName]
{
QMutexLocker locker( &sMutex );
QSqlDatabase::removeDatabase( connectionName );
Expand Down

0 comments on commit c782f27

Please sign in to comment.