From b69bb01f11f5104d8e807c7a2bdc92d3ffa394b4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 29 Jan 2012 20:32:22 +0100 Subject: Use QBasicMutex instead of Q_GLOBAL_STATIC QMutex QBasicMutex is a POD and can be used as a static global object. in qpicture.cpp factoryLoader is used only once, and under the mutex, so there is no need for Q_GLOBAL_STATIC for it, it can be a function static in qhostinfo_unix.cpp the code seemed wrong while compiled with namespace and QT_NO_GETADDRINFO. I also could get rid of one include because it was included earlier. Change-Id: I3c700203c3e067266c20733f4bda8031446dbb86 Reviewed-by: Bradley T. Hughes --- src/corelib/tools/qregexp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib/tools/qregexp.cpp') diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index 70cae5ceee9..421d15c436a 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -3809,7 +3809,7 @@ uint qHash(const QRegExpEngineKey &key) typedef QCache EngineCache; Q_GLOBAL_STATIC(EngineCache, globalEngineCache) -Q_GLOBAL_STATIC(QMutex, mutex) +static QBasicMutex globalEngineCacheMutex; #endif // QT_NO_REGEXP_OPTIM static void derefEngine(QRegExpEngine *eng, const QRegExpEngineKey &key) @@ -3817,7 +3817,7 @@ static void derefEngine(QRegExpEngine *eng, const QRegExpEngineKey &key) if (!eng->ref.deref()) { #if !defined(QT_NO_REGEXP_OPTIM) if (globalEngineCache()) { - QMutexLocker locker(mutex()); + QMutexLocker locker(&globalEngineCacheMutex); QT_TRY { globalEngineCache()->insert(key, eng, 4 + key.pattern.length() / 4); } QT_CATCH(const std::bad_alloc &) { @@ -3839,7 +3839,7 @@ static void prepareEngine_helper(QRegExpPrivate *priv) bool initMatchState = !priv->eng; #if !defined(QT_NO_REGEXP_OPTIM) if (!priv->eng && globalEngineCache()) { - QMutexLocker locker(mutex()); + QMutexLocker locker(&globalEngineCacheMutex); priv->eng = globalEngineCache()->take(priv->engineKey); if (priv->eng != 0) priv->eng->ref.ref(); -- cgit v1.2.3