Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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

(cherry-picked from 84d87a7)
  • Loading branch information
nyalldawson committed Jul 24, 2018
1 parent 7137a41 commit a1f8efa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/providers/wfs/qgswfsshareddata.cpp
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 a1f8efa

Please sign in to comment.