Skip to content

Commit 21a2f41

Browse files
rouaultdakcarto
authored andcommitted
Add QgsDataProvider::invalidateConnections() and implement in Spatialite provider
This invalidates all cached connections to the given database name. This will be used by the WFS provider to cleanup any cached connections before removing its temporary Spatialite DB (cherry-picked from 62bd406, necessary for offline plugin fix)
1 parent 0c54862 commit 21a2f41

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

python/core/qgsdataprovider.sip

+5
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ class QgsDataProvider : QObject
218218
*/
219219
virtual QgsError error() const;
220220

221+
/** Invalidate connections corresponding to specified name
222+
* @note added in QGIS 2.16
223+
*/
224+
virtual void invalidateConnections( const QString& connection );
225+
221226
signals:
222227

223228
/**

src/core/qgsdataprovider.h

+5
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ class CORE_EXPORT QgsDataProvider : public QObject
306306
*/
307307
virtual QgsError error() const { return mError; }
308308

309+
/** Invalidate connections corresponding to specified name
310+
* @note added in QGIS 2.16
311+
*/
312+
virtual void invalidateConnections( const QString& connection ) { Q_UNUSED( connection ); }
313+
309314
signals:
310315

311316
/**

src/providers/spatialite/qgsspatialiteprovider.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -5001,7 +5001,10 @@ const QgsField & QgsSpatiaLiteProvider::field( int index ) const
50015001
return attributeFields[index];
50025002
}
50035003

5004-
5004+
void QgsSpatiaLiteProvider::invalidateConnections( const QString& connection )
5005+
{
5006+
QgsSpatiaLiteConnPool::instance()->invalidateConnections( connection );
5007+
}
50055008

50065009
/**
50075010
* Class factory to return a pointer to a newly created

src/providers/spatialite/qgsspatialiteprovider.h

+2
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
233233
*/
234234
QgsAttributeList pkAttributeIndexes() override;
235235

236+
void invalidateConnections( const QString& connection ) override;
237+
236238
signals:
237239
/**
238240
* This is emitted whenever the worker thread has fully calculated the

0 commit comments

Comments
 (0)