Skip to content

Commit

Permalink
Fix a crash on start due to race condition in GDAL data items
Browse files Browse the repository at this point in the history
Thanks Radim for spotting this
  • Loading branch information
wonder-sk committed Jun 26, 2015
1 parent 7532000 commit a4b2cf8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/providers/gdal/qgsgdaldataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ QString QgsGdalLayerItem::layerName() const
static QString filterString;
static QStringList extensions = QStringList();
static QStringList wildcards = QStringList();
static QMutex gBuildingFilters;

QGISEXTERN int dataCapabilities()
{
Expand Down Expand Up @@ -186,9 +187,15 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
// get supported extensions
if ( extensions.isEmpty() )
{
buildSupportedRasterFileFilterAndExtensions( filterString, extensions, wildcards );
QgsDebugMsgLevel( "extensions: " + extensions.join( " " ), 2 );
QgsDebugMsgLevel( "wildcards: " + wildcards.join( " " ), 2 );
// this code may be executed by more threads at once!
// use a mutex to make sure this does not happen (so there's no crash on start)
QMutexLocker locker( &gBuildingFilters );
if ( extensions.isEmpty() )
{
buildSupportedRasterFileFilterAndExtensions( filterString, extensions, wildcards );
QgsDebugMsgLevel( "extensions: " + extensions.join( " " ), 2 );
QgsDebugMsgLevel( "wildcards: " + wildcards.join( " " ), 2 );
}
}

// skip *.aux.xml files (GDAL auxilary metadata files),
Expand Down

0 comments on commit a4b2cf8

Please sign in to comment.