From: Gunnar Sletta Date: Wed, 8 Feb 2012 07:06:17 +0000 (+0100) Subject: Use a singleton for the plugin. X-Git-Tag: qt-v5.0.0-alpha1~462 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d6f5913792f935ecc0bf8c382523d3daa1b8bf4;p=profile%2Fivi%2Fqtdeclarative.git Use a singleton for the plugin. The factory is created from the QQuickCanvas constructor before any alternative threads are started and doesn't need this kind of protected. In addition this caused problems on shutdown if multiple custom contexts where created. Change-Id: Ifdd9bde0c65aa7c399722aea33af78087a2465b4 Reviewed-by: Samuel Rødal --- diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp index 2a2268d..026afb2 100644 --- a/src/quick/scenegraph/qsgcontextplugin.cpp +++ b/src/quick/scenegraph/qsgcontextplugin.cpp @@ -79,14 +79,14 @@ struct QSGAdaptionPluginData QString deviceName; }; -QThreadStorage qsg_plugin_data; - +Q_GLOBAL_STATIC(QSGAdaptionPluginData, qsg_adaptation_data) QSGAdaptionPluginData *contextFactory() { - QSGAdaptionPluginData &plugin = qsg_plugin_data.localData(); - if (!plugin.tried) { - plugin.tried = true; + QSGAdaptionPluginData *plugin = qsg_adaptation_data(); + if (!plugin->tried) { + + plugin->tried = true; const QStringList args = QGuiApplication::arguments(); QString device; for (int index = 0; index < args.count(); ++index) { @@ -100,8 +100,8 @@ QSGAdaptionPluginData *contextFactory() #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) if (!device.isEmpty()) { - plugin.factory = qobject_cast(loader()->instance(device)); - plugin.deviceName = device; + plugin->factory = qobject_cast(loader()->instance(device)); + plugin->deviceName = device; } #ifndef QT_NO_DEBUG if (!device.isEmpty()) { @@ -114,7 +114,7 @@ QSGAdaptionPluginData *contextFactory() #endif // QT_NO_LIBRARY || QT_NO_SETTINGS } - return &plugin; + return plugin; }