summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorGirish Ramakrishnan <girish.1.ramakrishnan@nokia.com>2012-07-06 18:40:08 +0530
committerQt by Nokia <qt-info@nokia.com>2012-07-12 14:22:58 +0200
commitf56f542294b9368b77208a3c8077ffd97eb7fa5b (patch)
treef98b5668501bfe5578960f11b303b31b4b8c6bdc /src/gui/kernel
parent46c62433e8bd56e8284a086c2803f547b59e570e (diff)
QPA: pass cmdline arguments to QPlatformIntegrationPlugin constructor
Two observations of the current code: 1. The cmdline arguments are passed as dynamic properties of the native interface. This is not optimal. First, the args should be made available in the plugin constructor (and thus in the QPlatformIntegration constructor). This allows the integration to make decisions when initializing itself. Second, the preferred way for apps to query properties from the platform plugin should be through the various methods in QPlatformNativeInterface. With that in mind, the dynamic property approach should be obsoleted. I have left the code as-is for backward compat. 2. The -platform argument is parsed twice. Once in init_platform and then again in QPlatformIntegrationFactory. QPlatformIntegrationFactory now takes the name and arg list separately. Change-Id: I6b568ed9e28feeaf036bf340417fa00bdf1b7da3 Reviewed-by: Romain Pokrzywka <romain.pokrzywka@kdab.com> Reviewed-by: Oliver Wolff <oliver.wolff@nokia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp13
-rw-r--r--src/gui/kernel/qplatformintegrationfactory.cpp5
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_p.h2
3 files changed, 5 insertions, 15 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index a9986422c8..aa039cc947 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -665,18 +665,11 @@ QString QGuiApplication::platformName()
static void init_platform(const QString &pluginArgument, const QString &platformPluginPath)
{
// Split into platform name and arguments
- QString name;
- QStringList arguments;
- foreach (const QString &token, pluginArgument.split(QLatin1Char(':'))) {
- if (name.isEmpty()) {
- name = token;
- } else {
- arguments.push_back(token);
- }
- }
+ QStringList arguments = pluginArgument.split(QLatin1Char(':'));
+ const QString name = arguments.takeFirst().toLower();
// Create the platform integration.
- QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
+ QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, platformPluginPath);
if (QGuiApplicationPrivate::platform_integration) {
QGuiApplicationPrivate::platform_name = new QString(name);
} else {
diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp
index d1860da126..ce6b3bc293 100644
--- a/src/gui/kernel/qplatformintegrationfactory.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory.cpp
@@ -57,11 +57,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
(QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
#endif
-QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key, const QString &platformPluginPath)
+QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platform, const QStringList &paramList, const QString &platformPluginPath)
{
- QStringList paramList = key.split(QLatin1Char(':'));
- const QString platform = paramList.takeFirst().toLower();
-
#ifndef QT_NO_LIBRARY
// Try loading the plugin from platformPluginPath first:
if (!platformPluginPath.isEmpty()) {
diff --git a/src/gui/kernel/qplatformintegrationfactory_p.h b/src/gui/kernel/qplatformintegrationfactory_p.h
index 16cfa2803c..f3db44e1ab 100644
--- a/src/gui/kernel/qplatformintegrationfactory_p.h
+++ b/src/gui/kernel/qplatformintegrationfactory_p.h
@@ -66,7 +66,7 @@ class Q_GUI_EXPORT QPlatformIntegrationFactory
{
public:
static QStringList keys(const QString &platformPluginPath = QString());
- static QPlatformIntegration *create(const QString &key, const QString &platformPluginPath = QString());
+ static QPlatformIntegration *create(const QString &name, const QStringList &args, const QString &platformPluginPath = QString());
};
QT_END_NAMESPACE