From 7d6f5913792f935ecc0bf8c382523d3daa1b8bf4 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 8 Feb 2012 08:06:17 +0100 Subject: [PATCH] Use a singleton for the plugin. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/quick/scenegraph/qsgcontextplugin.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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; } -- 2.7.4