Skip to content
Permalink
Browse files

Add QgsDataProvider::invalidateConnections() and implement in Spatial…

…ite 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
  • Loading branch information
rouault committed Apr 5, 2016
1 parent c178aef commit 62bd4061fe3993501d94793f2eec0a01af281794
@@ -218,6 +218,11 @@ class QgsDataProvider : QObject
*/
virtual QgsError error() const;

/** Invalidate connections corresponding to specified name
* @note added in QGIS 2.16
*/
virtual void invalidateConnections( const QString& connection );

signals:

/**
@@ -306,6 +306,11 @@ class CORE_EXPORT QgsDataProvider : public QObject
*/
virtual QgsError error() const { return mError; }

/** Invalidate connections corresponding to specified name
* @note added in QGIS 2.16
*/
virtual void invalidateConnections( const QString& connection ) { Q_UNUSED( connection ); }

signals:

/**
@@ -461,7 +461,9 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
char* errMsg = nullptr;
int ret = sqlite3_exec( sqliteHandle, ( "PRAGMA " + pragma ).toUtf8(), nullptr, nullptr, &errMsg );
if ( ret != SQLITE_OK )
{
QgsDebugMsg( QString( "PRAGMA " ) + pragma + QString( " failed : %1" ).arg( errMsg ? errMsg : "" ) );
}
sqlite3_free( errMsg );
}
}
@@ -5014,7 +5016,10 @@ const QgsField & QgsSpatiaLiteProvider::field( int index ) const
return attributeFields[index];
}


void QgsSpatiaLiteProvider::invalidateConnections( const QString& connection )
{
QgsSpatiaLiteConnPool::instance()->invalidateConnections( connection );
}

/**
* Class factory to return a pointer to a newly created
@@ -233,6 +233,8 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
*/
QgsAttributeList pkAttributeIndexes() override;

void invalidateConnections( const QString& connection ) override;

signals:
/**
* This is emitted whenever the worker thread has fully calculated the

0 comments on commit 62bd406

Please sign in to comment.
You can’t perform that action at this time.