From 96218681f22588b93999626684ec73717207bb39 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Sun, 14 Oct 2018 20:26:38 +0200 Subject: Restore "Do not create instance of QPlatformIntegration for invalid displays" This patch is amended version of 67cc8fea106c35c7ca75bf476667d07b3bbf3257, which was temporary reverted to simplify integration of conflicting patches. What was amended: - Dropped the factory interface. It is sufficiently clean to check for QXcbConnection::isConnected(). Task-number: QTBUG-68859 Change-Id: I810897b3ea20e356fc4d62e6f01231fd287962dc Reviewed-by: Johan Helsing Reviewed-by: Friedemann Kleint --- src/plugins/platforms/xcb/qxcbmain.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/xcb/qxcbmain.cpp') diff --git a/src/plugins/platforms/xcb/qxcbmain.cpp b/src/plugins/platforms/xcb/qxcbmain.cpp index f8cb9a9269..c1e37f3704 100644 --- a/src/plugins/platforms/xcb/qxcbmain.cpp +++ b/src/plugins/platforms/xcb/qxcbmain.cpp @@ -52,10 +52,16 @@ public: QPlatformIntegration* QXcbIntegrationPlugin::create(const QString& system, const QStringList& parameters, int &argc, char **argv) { - if (!system.compare(QLatin1String("xcb"), Qt::CaseInsensitive)) - return new QXcbIntegration(parameters, argc, argv); + if (!system.compare(QLatin1String("xcb"), Qt::CaseInsensitive)) { + auto xcbIntegration = new QXcbIntegration(parameters, argc, argv); + if (!xcbIntegration->hasDefaultConnection()) { + delete xcbIntegration; + return nullptr; + } + return xcbIntegration; + } - return 0; + return nullptr; } QT_END_NAMESPACE -- cgit v1.2.3