Skip to content

Commit a1f8efa

Browse files
committedJul 24, 2018
[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)
1 parent 7137a41 commit a1f8efa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎src/providers/wfs/qgswfsshareddata.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ bool QgsWFSSharedData::createCache()
213213
{
214214
Q_ASSERT( mCacheDbname.isEmpty() );
215215

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.