summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-02-21 09:41:46 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-02-21 09:41:47 +0100
commitb949c447831d65fcf1a00feea151cd94a1021ed3 (patch)
treeb34704f92cb8b439e3f74930abf8cbf1b79b2c63 /src/gui/kernel
parent24ccb402e56d7b2728ceb68cccf12d68e6f7d11f (diff)
parent8dbd245979dac890c9317a27067a43205314a4f0 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp87
1 files changed, 51 insertions, 36 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index f7da94d111..12390928f0 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -525,21 +525,21 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME
\li \c{-platform} \e {platformName[:options]}, specifies the
\l{Qt Platform Abstraction} (QPA) plugin.
- Overridden by the \c QT_QPA_PLATFORM environment variable.
+ Overrides the \c QT_QPA_PLATFORM environment variable.
\li \c{-platformpluginpath} \e path, specifies the path to platform
plugins.
- Overridden by the \c QT_QPA_PLATFORM_PLUGIN_PATH environment
- variable.
+ Overrides the \c QT_QPA_PLATFORM_PLUGIN_PATH environment variable.
\li \c{-platformtheme} \e platformTheme, specifies the platform theme.
- Overridden by the \c QT_QPA_PLATFORMTHEME environment variable.
+ Overrides the \c QT_QPA_PLATFORMTHEME environment variable.
\li \c{-plugin} \e plugin, specifies additional plugins to load. The argument
may appear multiple times.
- Overridden by the \c QT_QPA_GENERIC_PLUGINS environment variable.
+ Concatenated with the plugins in the \c QT_QPA_GENERIC_PLUGINS environment
+ variable.
\li \c{-qmljsdebugger=}, activates the QML/JS debugger with a specified port.
The value must be of format \c{port:1234}\e{[,block]}, where
@@ -1125,6 +1125,8 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
\li \c openwfd
\li \c qnx
\li \c windows
+ \li \c wayland is a platform plugin for modern Linux desktops and some
+ embedded systems.
\li \c xcb is the X11 plugin used on regular desktop Linux platforms.
\endlist
@@ -1138,33 +1140,47 @@ QString QGuiApplication::platformName()
*QGuiApplicationPrivate::platform_name : QString();
}
-static void init_platform(const QString &pluginArgument, const QString &platformPluginPath, const QString &platformThemeName, int &argc, char **argv)
-{
- // Split into platform name and arguments
- QStringList arguments = pluginArgument.split(QLatin1Char(':'));
- const QString name = arguments.takeFirst().toLower();
- QString argumentsKey = name;
- argumentsKey[0] = argumentsKey.at(0).toUpper();
- arguments.append(QLibraryInfo::platformPluginArguments(argumentsKey));
+Q_LOGGING_CATEGORY(lcQpaPluginLoading, "qt.qpa.plugin");
+
+static void init_platform(const QString &pluginNamesWithArguments, const QString &platformPluginPath, const QString &platformThemeName, int &argc, char **argv)
+{
+ QStringList plugins = pluginNamesWithArguments.split(QLatin1Char(';'));
+ QStringList platformArguments;
+ QStringList availablePlugins = QPlatformIntegrationFactory::keys(platformPluginPath);
+ for (auto pluginArgument : plugins) {
+ // Split into platform name and arguments
+ QStringList arguments = pluginArgument.split(QLatin1Char(':'));
+ const QString name = arguments.takeFirst().toLower();
+ QString argumentsKey = name;
+ argumentsKey[0] = argumentsKey.at(0).toUpper();
+ arguments.append(QLibraryInfo::platformPluginArguments(argumentsKey));
+
+ // Create the platform integration.
+ QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, argc, argv, platformPluginPath);
+ if (Q_UNLIKELY(!QGuiApplicationPrivate::platform_integration)) {
+ if (availablePlugins.contains(name)) {
+ qCInfo(lcQpaPluginLoading).nospace().noquote()
+ << "Could not load the Qt platform plugin \"" << name << "\" in \""
+ << QDir::toNativeSeparators(platformPluginPath) << "\" even though it was found.";
+ } else {
+ qCWarning(lcQpaPluginLoading).nospace().noquote()
+ << "Could not find the Qt platform plugin \"" << name << "\" in \""
+ << QDir::toNativeSeparators(platformPluginPath) << "\"";
+ }
+ } else {
+ QGuiApplicationPrivate::platform_name = new QString(name);
+ platformArguments = arguments;
+ break;
+ }
+ }
- // Create the platform integration.
- QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, argc, argv, platformPluginPath);
if (Q_UNLIKELY(!QGuiApplicationPrivate::platform_integration)) {
- QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
+ QString fatalMessage = QStringLiteral("This application failed to start because no Qt platform plugin could be initialized. "
+ "Reinstalling the application may fix this problem.\n");
- QString fatalMessage;
- if (keys.contains(name)) {
- fatalMessage = QStringLiteral("This application failed to start because it could not load the Qt platform plugin \"%2\"\nin \"%3\", even though it was found. ").arg(name, QDir::toNativeSeparators(platformPluginPath));
- fatalMessage += QStringLiteral("This is usually due to missing dependencies, which you can verify by setting the env variable QT_DEBUG_PLUGINS to 1.\n\n");
- } else {
- fatalMessage = QStringLiteral("This application failed to start because it could not find the Qt platform plugin \"%2\"\nin \"%3\".\n\n").arg(name, QDir::toNativeSeparators(platformPluginPath));
- }
+ if (!availablePlugins.isEmpty())
+ fatalMessage += QStringLiteral("\nAvailable platform plugins are: %1.\n").arg(availablePlugins.join(QLatin1String(", ")));
- if (!keys.isEmpty()) {
- fatalMessage += QStringLiteral("Available platform plugins are: %1.\n\n").arg(
- keys.join(QLatin1String(", ")));
- }
- fatalMessage += QStringLiteral("Reinstalling the application may fix this problem.");
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// Windows: Display message box unless it is a console application
// or debug build showing an assert box.
@@ -1172,11 +1188,10 @@ static void init_platform(const QString &pluginArgument, const QString &platform
MessageBox(0, (LPCTSTR)fatalMessage.utf16(), (LPCTSTR)(QCoreApplication::applicationName().utf16()), MB_OK | MB_ICONERROR);
#endif // Q_OS_WIN && !Q_OS_WINRT
qFatal("%s", qPrintable(fatalMessage));
+
return;
}
- QGuiApplicationPrivate::platform_name = new QString(name);
-
// Many platforms have created QScreens at this point. Finish initializing
// QHighDpiScaling to be prepared for early calls to qt_defaultDpi().
if (QGuiApplication::primaryScreen()) {
@@ -1223,9 +1238,9 @@ static void init_platform(const QString &pluginArgument, const QString &platform
#ifndef QT_NO_PROPERTIES
// Set arguments as dynamic properties on the native interface as
// boolean 'foo' or strings: 'foo=bar'
- if (!arguments.isEmpty()) {
+ if (!platformArguments.isEmpty()) {
if (QObject *nativeInterface = QGuiApplicationPrivate::platform_integration->nativeInterface()) {
- for (const QString &argument : qAsConst(arguments)) {
+ for (const QString &argument : qAsConst(platformArguments)) {
const int equalsPos = argument.indexOf(QLatin1Char('='));
const QByteArray name =
equalsPos != -1 ? argument.left(equalsPos).toUtf8() : argument.toUtf8();
@@ -1289,7 +1304,7 @@ void QGuiApplicationPrivate::createPlatformIntegration()
argv[j++] = argv[i];
continue;
}
- const bool isXcb = platformName == "xcb";
+ const bool xcbIsDefault = platformName.startsWith("xcb");
const char *arg = argv[i];
if (arg[1] == '-') // startsWith("--")
++arg;
@@ -1302,13 +1317,13 @@ void QGuiApplicationPrivate::createPlatformIntegration()
} else if (strcmp(arg, "-platformtheme") == 0) {
if (++i < argc)
platformThemeName = QString::fromLocal8Bit(argv[i]);
- } else if (strcmp(arg, "-qwindowgeometry") == 0 || (isXcb && strcmp(arg, "-geometry") == 0)) {
+ } else if (strcmp(arg, "-qwindowgeometry") == 0 || (xcbIsDefault && strcmp(arg, "-geometry") == 0)) {
if (++i < argc)
windowGeometrySpecification = QWindowGeometrySpecification::fromArgument(argv[i]);
- } else if (strcmp(arg, "-qwindowtitle") == 0 || (isXcb && strcmp(arg, "-title") == 0)) {
+ } else if (strcmp(arg, "-qwindowtitle") == 0 || (xcbIsDefault && strcmp(arg, "-title") == 0)) {
if (++i < argc)
firstWindowTitle = QString::fromLocal8Bit(argv[i]);
- } else if (strcmp(arg, "-qwindowicon") == 0 || (isXcb && strcmp(arg, "-icon") == 0)) {
+ } else if (strcmp(arg, "-qwindowicon") == 0 || (xcbIsDefault && strcmp(arg, "-icon") == 0)) {
if (++i < argc) {
icon = QString::fromLocal8Bit(argv[i]);
}