diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-07-13 23:52:13 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-16 00:24:22 +0000 |
commit | c268afbd0a23d04653833cf6db474535277075cf (patch) | |
tree | 20bb8510fd3917b9604d14981eb81ce18e79625d /src/corelib/kernel/qcoreapplication.h | |
parent | 751ec5f2ffe87a52702f025756b74bd7e5ac0e07 (diff) |
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<QNativeInterface::QCocoaGLContext>();
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/qt/qtbase/src/gui/kernel/qguiapplication.h:176:5: note:
candidate template ignored: requirement
'NativeInterface<QNativeInterface::QCocoaGLContext>::isCompatibleWith<QGuiApplication>'
was not satisfied [with NativeInterface = QNativeInterface::QCocoaGLContext, TypeInfo =
QNativeInterface::Private::NativeInterface<QNativeInterface::QCocoaGLContext>, 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<QString>().
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.
Change-Id: Ie3f7e01ab7c3eb3dcc2ef730834f268bb9e81e0c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 1ef305de158498ba58063b19a02e40c9f6348857)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.h')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index cbb9d12040..873c0acf1f 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -164,7 +164,7 @@ public: const char * disambiguation = nullptr, int n = -1); - QT_DECLARE_NATIVE_INTERFACE_ACCESSOR + QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QCoreApplication) #ifndef QT_NO_QOBJECT #if QT_CONFIG(future) |