Skip to content

Commit

Permalink
[wfs] Fix race condition
Browse files Browse the repository at this point in the history
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 84d87a7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/providers/wfs/qgswfsshareddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit 84d87a7

Please sign in to comment.