From 1ef305de158498ba58063b19a02e40c9f6348857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 13 Jul 2021 23:52:13 +0200 Subject: Improve error reporting when requesting unsupported native interface By switching out the static_assert for an enable_if we end up producing a clearer error, at the call site: /qt/qtbase/examples/gui/rasterwindow/main.cpp:69:9: error: no matching member function for call to 'nativeInterface' app.nativeInterface(); ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /qt/qtbase/src/gui/kernel/qguiapplication.h:176:5: note: candidate template ignored: requirement 'NativeInterface::isCompatibleWith' was not satisfied [with NativeInterface = QNativeInterface::QCocoaGLContext, TypeInfo = QNativeInterface::Private::NativeInterface, BaseType = QGuiApplication] QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QGuiApplication) ^ By using SFINAE for the TypeInfo we can also ensure that it works for types that are not native interfaces, such as if the user tries to call nativeInterface(). Since we can no longer use decltype(*this) to resolve the base type we need to change QT_DECLARE_NATIVE_INTERFACE_ACCESSOR to take the type as an argument, as we do for other QT_DECLARE_FOO macros. Pick-to: 6.2 Change-Id: Ie3f7e01ab7c3eb3dcc2ef730834f268bb9e81e0c Reviewed-by: Qt CI Bot Reviewed-by: Fabian Kosmale --- src/gui/kernel/qguiapplication.h | 2 +- src/gui/kernel/qkeymapper_p.h | 2 +- src/gui/kernel/qoffscreensurface.h | 2 +- src/gui/kernel/qopenglcontext.h | 2 +- src/gui/kernel/qscreen.h | 2 +- src/gui/kernel/qwindow.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h index ba3d464bc8..795a88f2b0 100644 --- a/src/gui/kernel/qguiapplication.h +++ b/src/gui/kernel/qguiapplication.h @@ -173,7 +173,7 @@ public: bool isSavingSession() const; #endif - QT_DECLARE_NATIVE_INTERFACE_ACCESSOR + QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QGuiApplication) static void sync(); Q_SIGNALS: diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h index 9f061a9eb7..0297a69e28 100644 --- a/src/gui/kernel/qkeymapper_p.h +++ b/src/gui/kernel/qkeymapper_p.h @@ -73,7 +73,7 @@ public: static void changeKeyboard(); static QList possibleKeys(QKeyEvent *e); - QT_DECLARE_NATIVE_INTERFACE_ACCESSOR + QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QKeyMapper) private: friend QKeyMapperPrivate *qt_keymapper_private(); diff --git a/src/gui/kernel/qoffscreensurface.h b/src/gui/kernel/qoffscreensurface.h index e63c85cb72..6ed063b8c9 100644 --- a/src/gui/kernel/qoffscreensurface.h +++ b/src/gui/kernel/qoffscreensurface.h @@ -80,7 +80,7 @@ public: QPlatformOffscreenSurface *handle() const; - QT_DECLARE_NATIVE_INTERFACE_ACCESSOR + QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QOffscreenSurface) Q_SIGNALS: void screenChanged(QScreen *screen); diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h index 4d8c568ed5..b258fe0b7b 100644 --- a/src/gui/kernel/qopenglcontext.h +++ b/src/gui/kernel/qopenglcontext.h @@ -154,7 +154,7 @@ public: static bool supportsThreadedOpenGL(); static QOpenGLContext *globalShareContext(); - QT_DECLARE_NATIVE_INTERFACE_ACCESSOR + QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QOpenGLContext) Q_SIGNALS: void aboutToBeDestroyed(); diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h index 33778786e5..8c2f0cf10f 100644 --- a/src/gui/kernel/qscreen.h +++ b/src/gui/kernel/qscreen.h @@ -153,7 +153,7 @@ public: qreal refreshRate() const; - QT_DECLARE_NATIVE_INTERFACE_ACCESSOR + QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QScreen) Q_SIGNALS: void geometryChanged(const QRect &geometry); diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index d20694f625..102a324366 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -289,7 +289,7 @@ public: QVulkanInstance *vulkanInstance() const; #endif - QT_DECLARE_NATIVE_INTERFACE_ACCESSOR + QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QWindow) public Q_SLOTS: Q_REVISION(2, 1) void requestActivate(); -- cgit v1.2.3