From e16f74247958329263b59fe1b9ad8bd2a25de564 Mon Sep 17 00:00:00 2001 From: Jaroslaw Kubik Date: Sat, 2 Jul 2022 01:03:43 +0200 Subject: [PATCH] Provide a native interface instance in minimal platform plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The minimal platform plugin does not have any native APIs it could offer through that interface, but needs to provide an instance anyway. A lot of code within Qt assumes that a native interface is always available and does not check the pointer value, which leads to segfaults when used with the minimal plugin. Pick-to: 6.4 6.3 6.2 5.15 Change-Id: I625bd95afd49872cff3a34b29ceb0ffbbcd39db7 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/minimal/qminimalintegration.cpp | 8 ++++++++ src/plugins/platforms/minimal/qminimalintegration.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index 7523a2d966..a145093872 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -157,6 +158,13 @@ QAbstractEventDispatcher *QMinimalIntegration::createEventDispatcher() const #endif } +QPlatformNativeInterface *QMinimalIntegration::nativeInterface() const +{ + if (!m_nativeInterface) + m_nativeInterface.reset(new QPlatformNativeInterface); + return m_nativeInterface.get(); +} + QMinimalIntegration *QMinimalIntegration::instance() { return static_cast(QGuiApplicationPrivate::platformIntegration()); diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h index 914f26bf25..6070972b1b 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.h +++ b/src/plugins/platforms/minimal/qminimalintegration.h @@ -7,6 +7,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE class QMinimalScreen : public QPlatformScreen @@ -46,12 +48,15 @@ public: QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; QAbstractEventDispatcher *createEventDispatcher() const override; + QPlatformNativeInterface *nativeInterface() const override; + unsigned options() const { return m_options; } static QMinimalIntegration *instance(); private: mutable QPlatformFontDatabase *m_fontDatabase; + mutable QScopedPointer m_nativeInterface; QMinimalScreen *m_primaryScreen; unsigned m_options; };