Skip to content

Commit

Permalink
Merge pull request #2984 from rouault/fix_thread_unsafe_init_of_QgsEx…
Browse files Browse the repository at this point in the history
…pression_functions

Fix thread-unsafe initialization of QgsExpression::Functions()
  • Loading branch information
jef-n committed Apr 8, 2016
2 parents 9b9377f + d30836e commit 644eec6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/qgsexpression.cpp
Expand Up @@ -21,6 +21,7 @@
#include <QRegExp>
#include <QColor>
#include <QUuid>
#include <QMutex>

#include <math.h>
#include <limits>
Expand Down Expand Up @@ -2876,6 +2877,13 @@ QList<QgsExpression::Function*> QgsExpression::gmOwnedFunctions;

const QList<QgsExpression::Function*>& QgsExpression::Functions()
{
// The construction of the list isn't thread-safe, and without the mutex,
// crashes in the WFS provider may occur, since it can parse expressions
// in parallel.
// The mutex needs to be recursive.
static QMutex sFunctionsMutex( QMutex::Recursive );
QMutexLocker locker( &sFunctionsMutex );

if ( gmFunctions.isEmpty() )
{
gmFunctions
Expand Down

0 comments on commit 644eec6

Please sign in to comment.