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/gui/image/qpicture.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/gui/image/qpicture.cpp') diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index f9f96f4f13..089cc5011c 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -1425,20 +1425,16 @@ QPictureHandler::QPictureHandler(const char *f, const char *h, const QByteArray& typedef QList QPHList; Q_GLOBAL_STATIC(QPHList, pictureHandlers) -#ifndef QT_NO_LIBRARY -Q_GLOBAL_STATIC(QMutex, mutex) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, factoryLoader, - (QPictureFormatInterface_iid, - QLatin1String("/pictureformats"))) -#endif void qt_init_picture_plugins() { #ifndef QT_NO_LIBRARY - QMutexLocker locker(mutex()); - QFactoryLoader *loader = factoryLoader(); - QStringList keys = loader->keys(); + static QBasicMutex mutex; + QMutexLocker locker(&mutex); + static QFactoryLoader loader(QPictureFormatInterface_iid, + QStringLiteral("/pictureformats")); + QStringList keys = loader.keys(); for (int i = 0; i < keys.count(); ++i) - if (QPictureFormatInterface *format = qobject_cast(loader->instance(keys.at(i)))) + if (QPictureFormatInterface *format = qobject_cast(loader.instance(keys.at(i)))) format->installIOHandler(keys.at(i)); #endif } -- cgit v1.2.3