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>
This commit is contained in:
parent
46c62433e8
commit
f56f542294
@ -665,18 +665,11 @@ QString QGuiApplication::platformName()
|
|||||||
static void init_platform(const QString &pluginArgument, const QString &platformPluginPath)
|
static void init_platform(const QString &pluginArgument, const QString &platformPluginPath)
|
||||||
{
|
{
|
||||||
// Split into platform name and arguments
|
// Split into platform name and arguments
|
||||||
QString name;
|
QStringList arguments = pluginArgument.split(QLatin1Char(':'));
|
||||||
QStringList arguments;
|
const QString name = arguments.takeFirst().toLower();
|
||||||
foreach (const QString &token, pluginArgument.split(QLatin1Char(':'))) {
|
|
||||||
if (name.isEmpty()) {
|
|
||||||
name = token;
|
|
||||||
} else {
|
|
||||||
arguments.push_back(token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the platform integration.
|
// Create the platform integration.
|
||||||
QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
|
QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, platformPluginPath);
|
||||||
if (QGuiApplicationPrivate::platform_integration) {
|
if (QGuiApplicationPrivate::platform_integration) {
|
||||||
QGuiApplicationPrivate::platform_name = new QString(name);
|
QGuiApplicationPrivate::platform_name = new QString(name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,11 +57,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
|
|||||||
(QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
|
(QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key, const QString &platformPluginPath)
|
QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platform, const QStringList ¶mList, const QString &platformPluginPath)
|
||||||
{
|
{
|
||||||
QStringList paramList = key.split(QLatin1Char(':'));
|
|
||||||
const QString platform = paramList.takeFirst().toLower();
|
|
||||||
|
|
||||||
#ifndef QT_NO_LIBRARY
|
#ifndef QT_NO_LIBRARY
|
||||||
// Try loading the plugin from platformPluginPath first:
|
// Try loading the plugin from platformPluginPath first:
|
||||||
if (!platformPluginPath.isEmpty()) {
|
if (!platformPluginPath.isEmpty()) {
|
||||||
|
@ -66,7 +66,7 @@ class Q_GUI_EXPORT QPlatformIntegrationFactory
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static QStringList keys(const QString &platformPluginPath = QString());
|
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
|
QT_END_NAMESPACE
|
||||||
|
Loading…
Reference in New Issue
Block a user