mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Connection pool fixes
This commit is contained in:
parent
72c9830178
commit
a6bf6e9a6b
@ -123,9 +123,8 @@ class QgsConnectionPoolGroup
|
||||
|
||||
void release( T conn )
|
||||
{
|
||||
acquiredConns.removeAll( conn );
|
||||
|
||||
connMutex.lock();
|
||||
acquiredConns.removeAll( conn );
|
||||
Item i;
|
||||
i.c = conn;
|
||||
i.lastUsedTime = QTime::currentTime();
|
||||
@ -255,6 +254,20 @@ class QgsConnectionPool
|
||||
group->release( conn );
|
||||
}
|
||||
|
||||
//! Invalidates all connections to the specified resource.
|
||||
//! The internal state of certain handles (for instance OGR) are altered
|
||||
//! when a dataset is modified. Consquently, all open handles need to be
|
||||
//! invalidated when such datasets are changed to ensure the handles are
|
||||
//! refreshed. See the OGR provider for an example where this is needed.
|
||||
void invalidateConnections( const QString& connInfo )
|
||||
{
|
||||
mMutex.lock();
|
||||
if ( mGroups.contains( connInfo ) )
|
||||
mGroups[connInfo]->invalidateConnections();
|
||||
mMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
T_Groups mGroups;
|
||||
QMutex mMutex;
|
||||
|
@ -31,11 +31,3 @@ QgsOgrConnPool::~QgsOgrConnPool()
|
||||
{
|
||||
QgsDebugCall;
|
||||
}
|
||||
|
||||
void QgsOgrConnPool::invalidateHandles( const QString& connInfo )
|
||||
{
|
||||
mMutex.lock();
|
||||
if ( mGroups.contains( connInfo ) )
|
||||
mGroups[connInfo]->invalidateConnections();
|
||||
mMutex.unlock();
|
||||
}
|
||||
|
@ -79,8 +79,6 @@ class QgsOgrConnPool : public QgsConnectionPool<QgsOgrConn*, QgsOgrConnPoolGroup
|
||||
public:
|
||||
static QgsOgrConnPool* instance();
|
||||
|
||||
void invalidateHandles( const QString& connInfo );
|
||||
|
||||
protected:
|
||||
Q_DISABLE_COPY( QgsOgrConnPool )
|
||||
|
||||
|
@ -741,7 +741,7 @@ OGRwkbGeometryType QgsOgrProvider::getOgrGeomType( OGRLayerH ogrLayer )
|
||||
|
||||
void QgsOgrProvider::loadFields()
|
||||
{
|
||||
QgsOgrConnPool::instance()->invalidateHandles( filePath() );
|
||||
QgsOgrConnPool::instance()->invalidateConnections( filePath() );
|
||||
//the attribute fields need to be read again when the encoding changes
|
||||
mAttributeFields.clear();
|
||||
|
||||
@ -2524,7 +2524,7 @@ void QgsOgrProvider::recalculateFeatureCount()
|
||||
OGR_L_SetSpatialFilter( ogrLayer, filter );
|
||||
}
|
||||
|
||||
QgsOgrConnPool::instance()->invalidateHandles( filePath() );
|
||||
QgsOgrConnPool::instance()->invalidateConnections( filePath() );
|
||||
}
|
||||
|
||||
OGRwkbGeometryType QgsOgrProvider::ogrWkbSingleFlatten( OGRwkbGeometryType type )
|
||||
|
Loading…
x
Reference in New Issue
Block a user