Skip to content
Permalink
Browse files

[wfs] Fix race condition

Leads to multiple threads trying to create a cache db with the
same path, causing various crashes within the WFS iterator
  • Loading branch information
nyalldawson committed Jul 24, 2018
1 parent 3b47116 commit 84d87a757089540254bbeea7ada918ed5eb6bc77
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/providers/wfs/qgswfsshareddata.cpp
@@ -213,9 +213,10 @@ bool QgsWFSSharedData::createCache()
{
Q_ASSERT( mCacheDbname.isEmpty() );

static int sTmpCounter = 0;
++sTmpCounter;
mCacheDbname = QDir( QgsWFSUtils::acquireCacheDirectory() ).filePath( QStringLiteral( "wfs_cache_%1.sqlite" ).arg( sTmpCounter ) );
static QAtomicInt sTmpCounter = 0;
int tmpCounter = ++sTmpCounter;
mCacheDbname = QDir( QgsWFSUtils::acquireCacheDirectory() ).filePath( QStringLiteral( "wfs_cache_%1.sqlite" ).arg( tmpCounter ) );
Q_ASSERT( !QFile::exists( mCacheDbname ) );

QgsFields cacheFields;
Q_FOREACH ( const QgsField &field, mFields )

0 comments on commit 84d87a7

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