Skip to content
Permalink
Browse files

[Spatialite] Handle connection invalidation

This will be used by the WFS provider, so it can properly invalidates
(=close) all connections to the temporary Spatialite database it uses
for caching. Closing those connections is needed to be able to remove
the file.
  • Loading branch information
rouault committed Apr 5, 2016
1 parent e792576 commit c3760ec448f77cc981bfbf7d29600690cca17561
@@ -131,7 +131,7 @@ class QgsSqliteHandle
//
public:
QgsSqliteHandle( sqlite3 * handle, const QString& dbPath, bool shared )
: ref( shared ? 1 : -1 ), sqlite_handle( handle ), mDbPath( dbPath )
: ref( shared ? 1 : -1 ), sqlite_handle( handle ), mDbPath( dbPath ), mIsValid( true )
{
}

@@ -145,6 +145,16 @@ class QgsSqliteHandle
return mDbPath;
}

bool isValid() const
{
return mIsValid;
}

void invalidate()
{
mIsValid = false;
}

//
// libsqlite3 wrapper
//
@@ -165,6 +175,7 @@ class QgsSqliteHandle
int ref;
sqlite3 *sqlite_handle;
QString mDbPath;
bool mIsValid;

static QMap < QString, QgsSqliteHandle * > handles;
};
@@ -36,13 +36,15 @@ inline void qgsConnectionPool_ConnectionDestroy( QgsSqliteHandle* c )

inline void qgsConnectionPool_InvalidateConnection( QgsSqliteHandle* c )
{
Q_UNUSED( c );
/* Invalidation is used in particular by the WFS provider that uses a */
/* temporary spatialite DB and want to delete it at some point. For that */
/* it must invalidate all handles pointing to it */
c->invalidate();
}

inline bool qgsConnectionPool_ConnectionIsValid( QgsSqliteHandle* c )
{
Q_UNUSED( c );
return true;
return c->isValid();
}


0 comments on commit c3760ec

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