Skip to content
Permalink
Browse files

Merge pull request #2984 from rouault/fix_thread_unsafe_init_of_QgsEx…

…pression_functions

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

#include <math.h>
#include <limits>
@@ -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

0 comments on commit 644eec6

Please sign in to comment.
You can’t perform that action at this time.