diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2012-02-08 08:06:17 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-08 16:06:52 +0100 |
commit | 7d6f5913792f935ecc0bf8c382523d3daa1b8bf4 (patch) | |
tree | 45830abbcbe3eb591733e3c911b18d1a64d0382c | |
parent | 9df2da5b9feab42d93548db701fc7f649fd362ab (diff) |
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 <samuel.rodal@nokia.com>
-rw-r--r-- | src/quick/scenegraph/qsgcontextplugin.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp index 2a2268db5c..026afb2d56 100644 --- a/src/quick/scenegraph/qsgcontextplugin.cpp +++ b/src/quick/scenegraph/qsgcontextplugin.cpp @@ -79,14 +79,14 @@ struct QSGAdaptionPluginData QString deviceName; }; -QThreadStorage<QSGAdaptionPluginData> 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<QSGContextFactoryInterface*>(loader()->instance(device)); - plugin.deviceName = device; + plugin->factory = qobject_cast<QSGContextFactoryInterface*>(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; } |