File tree Expand file tree Collapse file tree 4 files changed +23
-0
lines changed Expand file tree Collapse file tree 4 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,8 @@ class QgsVectorDataProvider : QgsDataProvider
320
320
*/
321
321
virtual QgsTransaction* transaction() const;
322
322
323
+ virtual void forceReload();
324
+
323
325
protected:
324
326
void clearMinMaxCache();
325
327
void fillMinMaxCache();
Original file line number Diff line number Diff line change @@ -371,6 +371,15 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
371
371
*/
372
372
virtual QgsTransaction* transaction () const { return 0 ; }
373
373
374
+ /* *
375
+ * Forces a reload of the underlying datasource if the provider implements this
376
+ * method.
377
+ * In particular on the OGR provider, a pooled connection will be invalidated.
378
+ * This forces QGIS to reopen a file or connection.
379
+ * This can be required if the underlying file is replaced.
380
+ */
381
+ virtual void forceReload () {}
382
+
374
383
protected:
375
384
void clearMinMaxCache ();
376
385
void fillMinMaxCache ();
Original file line number Diff line number Diff line change @@ -2439,6 +2439,11 @@ QByteArray QgsOgrProvider::quotedIdentifier( QByteArray field )
2439
2439
return QgsOgrUtils::quotedIdentifier ( field, ogrDriverName );
2440
2440
}
2441
2441
2442
+ void QgsOgrProvider::forceReload ()
2443
+ {
2444
+ QgsOgrConnPool::instance ()->invalidateConnections ( filePath () );
2445
+ }
2446
+
2442
2447
QByteArray QgsOgrUtils::quotedIdentifier ( QByteArray field, const QString& ogrDriverName )
2443
2448
{
2444
2449
if ( ogrDriverName == " MySQL" )
Original file line number Diff line number Diff line change @@ -263,6 +263,13 @@ class QgsOgrProvider : public QgsVectorDataProvider
263
263
264
264
QByteArray quotedIdentifier ( QByteArray field );
265
265
266
+ /* *
267
+ * A forced reload invalidates the underlying connection.
268
+ * E.g. in case a shapefile is replaced, the old file will be closed
269
+ * and the new file will be opened.
270
+ */
271
+ void forceReload ();
272
+
266
273
protected:
267
274
/* * Loads fields from input file to member attributeFields */
268
275
void loadFields ();
You can’t perform that action at this time.
0 commit comments