Reduce overhead for including qguiapplication.h by splitting
up qnativeinterface.h into a public and a private part.
[ChangeLog][Potentially Source-Incompatible Changes] The
qguiapplication.h header no longer implicitly includes
qloggingcategory.h. If your code depends on the transitive
include, explicitly include <QLoggingCategory> where needed.
Pick-to: 6.2
Task-number: QTBUG-97601
Change-Id: Ic02327a1c3092e21730160af5c59a9d58dc1239c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
The use of a freestanding function is not needed now that the name
doesn't alias the nativeInterface accessor function, and was just
adding complexity to the machinery.
People not familiar with the code will have an easier time following
the flow through the helper member function, and we no longer need
to declare our own export macros.
Pick-to: 6.2
Change-Id: I17530b7e89939cfc19ab8ffaa076b7129ae02dcf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
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.
Pick-to: 6.2
Change-Id: Ie3f7e01ab7c3eb3dcc2ef730834f268bb9e81e0c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>