summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreapplication_platform.h
Commit message (Collapse)AuthorAgeFilesLines
* Pass QDeadlineTimer by value in runOnAndroidMainThread()Assam Boudjelthia2021-08-021-4/+2
| | | | | | | | | Also change the timer default value to use QDeadlineTimer::Forever. Change-Id: Ia6d0101872a5d01b04e146cd9b2f90315cb8eb2e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 50f53b90220707664947f3d1f9468c466398ec31) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Android: Use the new runOnAndroidMainThread() callAssam Boudjelthia2021-06-071-1/+1
| | | | | | | | | | | | Remove the [&] capture in runOnAndroidMainThread() for void type. Replace the old private QtAndroidPrivate::runOnAndroidThread() with QAndroidApplication::runOnAndroidMainThread(). Task-number: QTBUG-90501 Change-Id: I41eaf1ea9ee68b22861bf498f12a97a02515cc47 Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Android: Add runOnMainAndroidThread() under QNativeInterfaceAssam Boudjelthia2021-05-261-0/+21
| | | | | | | | | | | | This replaces QtAndroidPrivate::runOnAndroidThread{Sync} calls. This also now allows passing std::function<> that can return values, and not only an std::function<void()>. This adds some tests for this calls as well. Fixes: QTBUG-90501 Change-Id: I138d2aae64be17347f7ff712d8a86edb49ea8350 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Android: fix missing includeMårten Nordheim2021-05-261-0/+1
| | | | | | | | qtbase/include/QtCore/../../../../src/qtbase/src/corelib/kernel/qcoreapplication_platform.h:58:57: error: unknown type name 'QCoreApplication' QT_DECLARE_NATIVE_INTERFACE(QAndroidApplication, 1, QCoreApplication) Change-Id: I0a14a2f2ab80f9cc0e7fd3b3060719a1c772bf57 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Rejig native interface plumbingTor Arne Vestbø2021-05-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The initial approach for providing public access to native interfaces via T::nativeInteface<I>() was based on the template not being defined, and then having explicit instantiations of the supported types in a source file, so that the accessors were exported and available to the user. This worked fine for "simple" types such as QOpenGLContext and QOffscreenSurface, but presented a problem in the context of classes with subclasses, such as Q{Core,Gui}Application. To ensure that a native interface for QCoreApplication was accessible both from QCoreApplication and its subclasses, while at the same time preventing a native interface for QGuiApplication to be accessible for QCoreApplication, the nativeInterface() template function had to be declared in each subclass. Which in turn meant specializing each native interface once for each subclass it was available in. This quickly became tedious to manage, and the requirements for exposing a new native interface wasn't very clear with all these template specializations and explicit instantiations spread around. To improve on this situation, while also squashing a few other birds at the same time, we change the approach to use type erasure. The definition of T::nativeInteface<I>() is now inline, passing on the requested interface to a per type (T, not I) helper function, with the interface type flattened to a std::type_info. The type_info requested by the user is then compared to the available types in a single per-type (T) "switch statement", which is a lot easier to follow for someone trying to trace the logic of how a native interface is resolved. We can safely rely on type_info being stable between the user application and the Qt library as a result of exporting the type info for each native interface, by explicitly ensuring they have a key function. This is the same mechanism that ensures we can safely dynamic_cast these interfaces, even across library boundaries. The use of a free standing templated helper function instead of a member function in the type T, is to avoid shadowing issues, and to not pollute the class namespace of T with the helper function. Since we are already changing the plumbing for how a user resolves a native interface for a type T, we take the opportunity to add a few extra safeguards to the machinery. First, we add a static assert in the T::nativeInteface<I>() definition, that ensures that only compatible interfaces, as declared by the interface themselves, are allowed. This ensures a compile time error when an incompatible interface is requested, which improves on the link time errors we had prior to this patch, and also offsets the one downside of type erasure, namely that errors are only caught at runtime. Secondly, each interface meant for public consumption through T::nativeInteface<I>() is declared with a revision, which is checked when requesting the interface. This allows us to bump the revision when we make breaking changes to the interface that would have otherwise been binary incompatible. Since the user will never see this interface due to the revision check, they will not end up calling methods that have been removed or renamed. One advantage of moving to a type-erased approach for the plumbing is that we're not longer exposing the native interface types as part of the T::nativeInteface symbols. This means that if we ever want to rename a native interface, the only exported symbol that the user code relies on is the type info. Renaming is then possible by just exporting the type info for the old interface, but leaving it empty. Since no class in Qt implements the old native interface, the user will just get a nullptr back, similarly to bumping the revision of an interface. Change-Id: Ie50d8fb536aafe2836370caacb22afbcfaf1712a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Move QNativeInterface helpers to their own header fileTor Arne Vestbø2021-05-101-0/+1
| | | | | | | | | The machinery is not needed for all translation units, so keep it out of qglobal.h. Change-Id: Ib0459a3f7bc036f56b0810eb750d4641f567f1fe Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Move hideSplashScreen() from qjnihelpers_p to QNativeInterfaceAssam Boudjelthia2021-05-081-0/+1
| | | | | | | | | | | | Hiding the splash screen require one JNI call instead of having to keep it as a global in qjnihelpers, and since it's not really easy to have a cross platform way for it it makes sense to have it under QNativeInterface. The alternative is probably removing it altogether since it's not useful often. Task-number: QTBUG-90500 Change-Id: I9b375c52afbf07e1ddd7957c1ec60af5c258f404 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Add sdkVersion() to QNativeInterface::QAndroidApplicationAssam Boudjelthia2021-05-061-0/+1
| | | | | | | | | | | The androidSdkVersion() is probably the most used call from QtAndroidPrivate, so instead of waiting long time for a cross platform api that could offer this functionality, it's better to have it now under the NativeInterface. Task-number: QTBUG-90497 Change-Id: I008d4c77d347d36e0a7e8ca4d6f33f993b02511b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add QAndroidApplication as a nativeInterfaceAssam Boudjelthia2021-02-201-0/+66
QAndroidApplication provides the Android specific app context() and isActivityContext() to determine whether the context is an Activity or otherwise a Service. Task-number: QTBUG-90499 Change-Id: Iae2eef7ec44859a89825b09f52f09506b20b5420 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>