summaryrefslogtreecommitdiffstats
path: root/src/corelib/platform
Commit message (Collapse)AuthorAgeFilesLines
* Fix documentation of QAndroidApplication::contextVolker Hilsheimer4 days1-2/+2
| | | | | | | | | | | | As of Qt 6.7 we no longer return jobjects from that API. The declared QJniType::Context type (and similar types) is no longer jobject-like, they are now QJniObject-like. Task-number: QTBUG-123900 Pick-to: 6.7 Change-Id: I215f84ac37907ae2b7950c40c7287590234e4e35 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Add preliminary support for Qt for visionOSTor Arne Vestbø6 days1-1/+12
| | | | | | | | | | | | | | | | | | | | | | Qt already runs on Vision Pro as "Designed for iPad", using Qt for iOS. This change enables building Qt for visionOS directly, which opens the door to visionOS specific APIs and use-cases such as volumes and immersive spaces. The platform removes some APIs we depend on, notably UIScreen, so some code paths have been disabled or mocked to get something up and running. As our current window management approach on UIKit platforms depends on UIWindow and UIScreen there is currently no way to bring up QWindows. This will improve once we refactor our window management to use window scenes. To configure for visionOS, pass -platform macx-visionos-clang, and optionally add -sdk xrsimulator to build for the simulator. Change-Id: I4eda55fc3fd06e12d30a188928487cf68940ee07 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Unseal overridden methods on QComObjectPavel Dubsky12 days1-3/+3
| | | | | | | | | There are cases where overriding AddRef, Release, and/or QueryInterface and adding additional functionality besides commonly required might be beneficial. Change-Id: I4407960164edf0441d1d054356f74abba6becbe7 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* wasm: Export haveJspi() for dynamic linkingPiotr Wierciński2024-02-291-1/+1
| | | | | | | | | | This symbol is required to be public in case of dynamic linking. Mark it with Q_CORE_EXPORT. Task-number: QTBUG-121839 Change-Id: Ie4b89532e39eb21f6efceefcceb922cd6d37983a Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* cmake: Generate Apple privacy manifest files for Qt modulesTor Arne Vestbø2024-02-131-0/+31
| | | | | | | | | | | | | | | | | | | The default manifest is a minimal file that claims NSPrivacyTracking false, along with an empty list of NSPrivacyTrackingDomains and NSPrivacyCollectedDataTypes, as Qt does not generally do user tracking. Modules can override the default manifest by setting the PRIVACY_MANIFEST target property, specifying a custom privacy manifest. The NSPrivacyAccessedAPITypes key is only required for iOS for now. Even though we don't build Qt for iOS as frameworks yet, which is required to embed a privacy manifest, we include the keys for the APIs we known we use. Task-number: QTBUG-114319 Change-Id: I654bb52b98ee963adeeb744b35f3a1c2a1270969 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* wasm: make EventCallback use addEventListener()Morten Sørvig2024-01-252-33/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | EventCallback would previously set the on<Event> property on the event target, which is a singleton property where there can be only one event handler. This was OK if the event target was owned by Qt, for example the canvas element, where we could guarantee that there was only one event handler. However this approach fell through when registering event handlers for global event targets, such as for window.onLanguageChange, where setting a singleton event handler may conflict with other users. Fix this by using the addEventListener() API instead, which has a variant which takes an event listener object, which gives us the ability to provide C++ context for the listener. The C++ context in this case is a std::function that contains the event handler callback. Attempts to pass this type to JavaScript was met with some resistance from Emscripten, so as a late night hack pass it as a uintptr_t for now. Change-Id: I1a547b49af467882ae4f57f8d909ffdff0be6b51 Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: Fix handling of promise pool in WebPromiseManagerPiotr Wiercinski2023-12-281-15/+12
| | | | | | | | | | | | | | | | | | | | | | | Promises are registered upon entry to the pool and unregistered upon exit. If all promises are in a 'pending' state, new promises can't be processed. Upon completion of a registered promise, it is unregistered, allowing space for a new promise. The code path responsible for unregistering promises when they resolve runs each time a promise's callback is called. Unfortunately, there's no guarantee that the callback will be invoked upon the promise's resolution. For instance, promises registered with only a 'catch' callback may never be triggered when the promise resolves correctly. This commit ensures that a final callback is always registered, even if the user did not provide one. This guarantees that promises are always unregistered upon resolution Fixes: QTBUG-118161 Pick-to: 6.5 6.6 6.7 Change-Id: Ifea93d692464a6ef40c4bcad60f840ca0cb650c9 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: move DataTransfer to dom::Lorn Potter2023-12-212-118/+0
| | | | | | Change-Id: I069292154bafd1c08a0d0f2e8a62052f596a80f3 Done-with: Mikolaj.Boc@qt.io Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: extend qstdweb to support objectUrls in FileLorn Potter2023-12-212-1/+57
| | | | | | Change-Id: If346f8afcf4578dedccce6f768e85c7750a9de3e Done-with: Mikolaj.Boc@qt.io Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Android: don't call delegates outside of the ActivityAssam Boudjelthia2023-11-101-2/+1
| | | | | | | | | | | | | | | | | | | | | The delegate classes shouldn't be used outside of the Activity/Service classes, since they're practically private implementation, so don't use them anywhere outside Activity/Service. Since Qt Android apps still mainly support having one QtActivity/ QtService, QtNative heavily uses those objects to do various operations. For that reason, we still need to use the delegate there. The aim is to change that in future patches and do the operations where they make more sense for example directly under QtActivityBase/QtActivityDelegate or Service counterpart. The QtServiceDelegate is used no where and have no special implementation, so it's removed here. Task-number: QTBUG-118077 Change-Id: I5e106318169be19fec8163e8e500ee573af0e1bc Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Android: add missing extras native methods impls and registrationAssam Boudjelthia2023-11-032-4/+42
| | | | | | | | | | This should have been done when the extras where moved to qtbase, it went under the rug and was forgotten. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-114971 Change-Id: Id7831a8bab8bedc1f869b9fc8bfc72acc3cca7a2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* wasm: fix null-argument warningMorten Sørvig2023-10-311-1/+1
| | | | | | | | | | | | | That's "null passed to a callee that requires a non-null argument". Pass EMSCRIPTEN_EVENT_TARGET_WINDOW instead of NULL to emscripten_set_wheel_callback. The function is never called here, so it does not matter which non-null value it gets. Pick-to: 6.6 Change-Id: I10187a222513820158a938bf05cde60f489956f1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Include what you need: QIODeviceVolker Hilsheimer2023-10-301-0/+1
| | | | | | | | | | | The qstdweb_p.h header declares subclasses of QIODevice and uses enum types declared in QIODeviceBase, so make sure we include the QIODevice header. Change-Id: Id23da64105f998d52b114b529ce8493c74ed2364 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io>
* Android: don't rely on implicit cast of declared QtJniTypes to jobjectVolker Hilsheimer2023-10-271-1/+1
| | | | | | | | | | The operator jobject() should be removed from declared QtJniTypes in qtbase, as it's dangerous. Prepare for that by calling object(), which returns the wrapped jobject as well, or isValid() where previously the implicit conversion to jobject also enabled implicit conversion to bool. Change-Id: I00cf6f1463dd5ab5cbaf03d9e77bfff3bced9b15 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* wasm: add QIODevices for accessing JS dataMorten Sørvig2023-10-252-0/+174
| | | | | | | | | | | | | | | | BlobIoDevice: Supports reading data from a JS Blob, which can be a File (on disk) or some other object which can provide data. The native access functions are async and using this class requires that asyncify is available. Uint8ArrayIODevice: Supports reading and writing to a Uint8Array / ArrayBuffer. Similar to the existing QByteArray::fromEcmaUint8Array() API, except that it supports incremental accesss. Change-Id: Ic5de3534ff75eb6c745287b73b15ccd92d74ac2c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Introduce QComObject base classPavel Dubsky2023-10-131-0/+127
| | | | | | | | | | | | This base class implementation for COM objects provides IUnknown interface implementation with reference counting which will allow to keep all this functionality and implementation in the same place. Pick-to 6.6 6.5 Change-Id: I8ec597b1040ac33295317e06338ffdcb61b78f85 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* wasm: make haveAsyncify() return true for any asyncifyMorten Sørvig2023-10-022-4/+22
| | | | | | | | | | | | | | | User code usually don't need to differentiate between asyncify 1 or 2 (JSPI), since the differences are abstracted over by the wasm event dispatcher. haveJspi() returns true for JSPI only as before, and can be used to differentiate between the two. Add canBlockCallingThread(), which returns true also for secondary threads (which don't need asyncify to block). Change-Id: Ia37513f2d4c56ef6351c950b5fc31ad15fa389d9 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: fix "'QString' is deprecated" warningsMorten Sørvig2023-09-131-5/+7
| | | | | | | | | | Use the _L1 operator from Qt::Literals::StringLiterals Pick-to: 6.6 Change-Id: I3d8dc0b7219879a1907e67b539e047ae7f7aae87 Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io> Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: Drop using deprecated functionPiotr Wiercinski2023-09-121-2/+2
| | | | | | | | | | The `emscripten_main_browser_thread_id()` has been deprecated in favor of `emscripten_main_runtime_thread_id()`. Using the deprecated one generates a warning during compilation. Change-Id: I1154bd8ff78f13e6425fdc65ac39763569360da6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: make all val() accessors constMorten Sørvig2023-09-072-10/+10
| | | | | | | | Enable using them in a const context, for instance when calling "const" native API. Change-Id: I0b3fe33ab7fabf4bda8565d4de88bb21367d356e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: rename JsString -> EcmaStringMorten Sørvig2023-08-301-1/+1
| | | | | | | | | | | | | QString::fromJsString -> QString::fromEcmaString() QString::toJsString() -> QString::toEcmaString() For API naming compatibility with QByteArray::fromEcmaUin8Array() Pick-to: 6.6 Change-Id: If6e2121e31e630d6728ed24e41d14b763f395aaa Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io> Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Move runTaskOnMainThread to qstdweb_p.h, use it in WASM dispatcherMikolaj Boc2023-08-251-0/+42
| | | | | | | | This unifies the approach to running sync tasks (possibly with a return value) on the main thread. Change-Id: I2a05c4f40115a79dbf03c03fa8d8db34124884dc Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* Core: include mocsMårten Nordheim2023-07-071-0/+2
| | | | | Change-Id: If116c090450836007dca826fba1754058fc754c0 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* permissions: Handle unknown permission statuses gracefullyTor Arne Vestbø2023-06-294-8/+17
| | | | | | | | | | | | If an application runs on a macOS or iOS version that introduces new permission statuses that we haven't accounted for, we don't want to crash. Replace Q_UNREACHABLE with a warning and Qt::PermissionStatus::Denied. Pick-to: 6.5 6.6 Change-Id: I063042f510caaa8936742f6195bd455d09c4d9ee Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* permissions: Handle EKAuthorizationStatusWriteOnly on macOS 14/iOS 17Tor Arne Vestbø2023-06-291-4/+16
| | | | | | | | | | | For now we do not have a QCalendarPermission::AccessMode::WriteOnly, so we have to report Qt::PermissionStatus::Denied. Fixes: QTBUG-114864 Pick-to: 6.5 6.6 Change-Id: I94e92912ef4c24adb524ccf2cf28553115d6781b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io>
* Introduce qstdweb::bindForever stub for submodule updateMikolaj Boc2023-06-151-0/+6
| | | | | | | | | | | | | | The qstdweb::bindForever function will be introduced soon for binding callbacks with forever lifetime. For now, since submodules have to be adapted first, introduce a stub function to port qtmultimedia which uses Promise::make - it will have its interface changed with relation to bindForever. Task-number: QTBUG-112296 Change-Id: I578e1633574e11877a8f5ec14d0f00dfd7c766bf Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io> Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Fix jsHaveJspi so that it works without Asyncify definedMikolaj Boc2023-06-141-1/+1
| | | | | | Change-Id: I3dd2ff16e41faae33c8095d7d8ea538da8c7d4d4 Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Adapt WASM event dispatcher to use JSPI, if availableMikolaj Boc2023-06-122-1/+11
| | | | | | | | | | | | | | | | | Detect if JSPI is available and suspend the execution of the program if so, instead of using 'bare' asyncify. For now: 1) This works only with emscripten 3.1.36 with mboc-qt patches from emscripten repo 2) Apps have to specify the following linker options: -sDYNCALLS=1 -sASYNCIFY=2 -sASYNCIFY_EXPORTS=dynCall_* Fixes: QTBUG-113570 Change-Id: Ide7c51e36990df7e20c6c9b5a218366cb0db100e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Remove FileReader callbacks before assigning new onesMikolaj Boc2023-04-251-3/+6
| | | | | | | | | This fixes the assert raised on overwriting event handlers Fixes: QTBUG-113041 Change-Id: Ie2afe09f4111ea542297b82a51382f1eb04ec960 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io>
* wasm: add setting type to BlobLorn Potter2023-04-212-3/+9
| | | | | | | | | | Blobs can be any mime type, add function that sets up mime type This allows Safari to play videos that are Blobs Pick-to: 6.5 Change-Id: Ide63851934058935d94f42721b246d832e3bcb85 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* Long live QtFuture::makeReadyVoidFuture() and QtFuture::makeReadyValueFuture()Ivan Solovev2023-04-051-3/+3
| | | | | | | | | | | | | | | | [ChangeLog][QtCore][QFuture] Added QtFuture::makeReadyVoidFuture() and QtFuture::makeReadyValueFuture(). Basically, these methods behave like QtFuture::makeReadyFuture(), but QtFuture::makeReadyValueFuture() does not have a "const QList<T> &" specialization returning QFuture<T> instead of QFuture<QList<T>>, which allows it to always behave consistently. This patch also introduces usage of the new methods around qtbase. Task-number: QTBUG-109677 Change-Id: I89df8b26d82c192baad69efb5df517a8b182995f Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Long live QtFuture::makeReadyRangeFuture()Ivan Solovev2023-04-051-1/+1
| | | | | | | | | | | | | | | | [ChangeLog][QtCore][QFuture] Introduce QtFuture::makeReadyRangeFuture(). This method takes a container which has input iterators and returns a multi-value QFuture<ValueType>, where ValueType is the underlying type of the input container. This commit also replaces the usage of buggy QtFuture::makeReadyFuture(const QList<T> &) overload with the new method. Task-number: QTBUG-109677 Change-Id: I019e62eac74c643d88a65b3cc0085bc7c33bc712 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* wasm: export qstdweb::readDataTransfer()Morten Sørvig2023-03-171-1/+1
| | | | | | | Fix shared libraries build. Change-Id: I7bf1c7d333b7d039905ee77cf954ba46549993d3 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* Fix compilation issues for androidMichal Klocek2023-03-161-0/+1
| | | | | | | | | | Deals with: * unknown class name 'Object'; did you mean 'QObject'? * use of undeclared identifier 'QTimer'; did you mean 'QTime'? Pick-to: 6.5 Change-Id: Id63064e70090ed1f816fa19db047b382220d634c Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Assert on overwriting a previously set EventCallback on wasmMikolaj Boc2023-02-141-0/+2
| | | | | | | | | Overwriting a previously set EventCallback may lead to subtle, hard-to-detect errors. Since it constitutes a programming error, assert on such attempts to detect potential event handling problems. Change-Id: I9d3647cbd0a1733741d16681cdad150c85848f97 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* permissions: Replace deprecated location permission usage keyTor Arne Vestbø2023-02-081-1/+5
| | | | | | | | | And add the macOS specific key. Pick-to: 6.5 Change-Id: I1e0446a1927ef530322388417b9300ae287752c3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Use qt_winrtbase_p.h workaround in more placesYuhang Zhao2023-02-071-2/+4
| | | | | | | | | | | | | | | | | This patch addresses the following issues: (1) some places are still using the original workaround, replace them with the new qt_winrtbase_p.h workaround. (2) add more comment to let people know how to workaround other cppwinrt issues (it was a common issue for many years and may be fixed upstream recently, but let's at least document it in case the user is still using old version cppwinrt). Amends commit b2c1237b4512480a17009afe1981af02c2a9869e Pick-to: 6.5 6.4 Change-Id: Ife676f41739bbe69d9fb23bf5758be4b1fab4855 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* iOS: Disallow upgrading QLocationPermission::WhenInUse to AlwaysTor Arne Vestbø2023-02-071-6/+14
| | | | | | | | | | | | | This is technically possible on iOS, but the system doesn't give us a callback unless the user accepts the upgraded permission level, and we need a deterministic callback in both cases so that we can report the result back to the permission request callback. https://tinyurl.com/requestalwaysauthorization Pick-to: 6.5 Change-Id: Id006dbbb2f6fad4b831742e4d3e904525aaa8a2a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* iOS: Report PermissionStatus::Denied when detecting accuracy mismatchTor Arne Vestbø2023-02-071-1/+1
| | | | | | | | | | | There's no way to upgrade an Approximate accuracy permission to Precise, so once we have a known status we report the lacking accuracy as Denied. Pick-to: 6.5 Change-Id: Id49af825335ff09669aa7f2285caaa744a5a4d24 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Apple: Detect missing bundle identifier when using location permissionsTor Arne Vestbø2023-02-021-0/+7
| | | | | | | | | | | | The location permissions database in /var/db/locationd/clients.plist ties the location permission to the bundle identifier (among other things), so a missing bundle identifier will result in the app asking repeatedly for the location permission, as the permission is never saved. Pick-to: 6.5 Change-Id: I64ab5b8f8762804869c0f97debd97da817787808 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Introduce qt_winrtbase_p.hOliver Wolff2023-01-232-1/+33
| | | | | | | | | | | | | | Due to a bug in earlier Windows SDKs developers have copy paste a workaround whenever they are including winrt/base.h. In addition to that our usage winrt API also forces them to include qfactorycacheregistration_p.h whenever they include that file. To make things easier all that magic can now be done with one single include of qt_winrtbase_p.h. Pick-to: 6.4 Change-Id: Ic6a80d6d3723af381cf0ecc0f0ab43c2e6839a7d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Streamline reading of js DataTransfer objectMikolaj Boc2023-01-182-3/+132
| | | | | | | | | | | | | | | | | | qwasmclipboard.cpp and qwasmdrag.cpp had the same logic that read the js DataTransfer object implemented twice with small differences. Use a single implementation in both. This also introduces a clearer memory ownership model in the reader code, and fixes a potential race condition by introducing a cancellation flag. Removed the useless QWasmDrag type which was in essence a SimpleDrag and made the m_drag in QWasmIntegration a smart pointer. Fixes: QTBUG-109626 Pick-to: 6.5 Change-Id: I5b76dd3b70ab2e5a8364d9a136c970ee8d4fae9c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QPermission: replace T data<T>() with std::optional<T> value<T>()Marc Mutz2023-01-131-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in API review, the default-constructed T() returned from a mismatched data<T>() call is indistinguishable from a real T with default state. To make them distinguishable, return optional<T>. Call the new function value<T>(), mimicking QVariant::value<T>(), and suggested in API review, because data() is usually used to return raw pointers, not values. Remove the qWarning() on requestedType and actualType mismatch, as the new function can be used in std::get_if/dynamic_cast-like if-then-else chains, in which failure is part of the normal operation, and a warning message misplaced: if (auto loc = perm.value<QLocationPermission>()) ~~~ use *loc ~~~ else if (auto con = perm.value<QContactsPermission>()) ~~~ use *con ~~~ ~~~ etc ~~~ Pick-to: 6.5 Change-Id: I799a58e930307323ebce8f9ac50a42455e9c017f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Android: requestPermissionsInternal(): use more makeReadyFuture()Marc Mutz2023-01-051-14/+13
| | | | | | | Only use an actual QPromise when the calculation will be async. Change-Id: I5900c6498f56721dd04c4da204c0270492f52eee Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Android: checkPermission/s(): use makeReadyFuture()Marc Mutz2023-01-041-20/+7
| | | | | | | | | | | | ... instead of manual QPromise handling. QtFuture::makeReadyFuture() is both more efficient and more readable. As a drive-by, replace size() > 0 checks with !isEmpty(). Change-Id: I299fbe8e6be10d8f65b8f86fcc6b586ac3cbd9d2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
* QAndroidExtras: release mutex earlier in requestPermissionsInternal()Marc Mutz2023-01-041-0/+1
| | | | | | | | | | | The g_pendingPermissionRequestsMutex protects only the g_pendingPermissionRequests QHash, so we can drop it immediately after the QHash::insert() call. In particular, we don't use reference into the QHash afterwards, and the following runOnAndroidMainThread() call is internally synchronized, anyway. Change-Id: I66a0e402e9ed1edb5fd9fec14e85f9371cc4fc36 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* runOnAndroidMainThread(): optimize shared pointer useMarc Mutz2022-12-261-2/+3
| | | | | | | | | | | | - port from QSharedPointer to std::shared_ptr (one instead of two atomic ops per shared-pointer copy) - port to std::make_shared (one instead of two memory allocations for shared-pointer + payload creation) Pick-to: 6.5 Change-Id: Idecef5732d181a63e6936f54204eeb7ecbdc4a0f Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Fix UB (reference to local variable leaving scope) in runOnAndroidMainThread()Marc Mutz2022-12-231-1/+1
| | | | | | | | | | | | | | | | | | | | The QAndroidApplication::runOnAndroidMainThread() function creates a task on QThreadPool::globalInstance() to wait for a timeout and cancel the QFuture representing the task. It does so by passing a lambda to QThreadPool::start(std::function) that captures the future, a local variable, by reference. This is UB when the lambda is ever executed, because the local stack variable's lifetime will have ended. To fix, simply capture the future by value, not by reference. Since QFuture::cancel() is not const, we need to make the lambda mutable. Fixes: QTBUG-109586 Pick-to: 6.5 6.4 6.2 Change-Id: Icacfb0dc76bcd3a145f90126f535e7c0f4b5ef6a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* QAndroidNaticeInterface: replace a pair with a structMarc Mutz2022-12-231-8/+15
| | | | | | | | | Nicer member names make the code using the type more readable. It also allows to add other members later. Pick-to: 6.5 6.4 6.2 Change-Id: I69f1f97673a8f1ad8eb73e4f1e5323eccf929413 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* runOnAndroidMainThread(): Use QThreadPool::start() instead of ↵Marc Mutz2022-12-231-2/+4
| | | | | | | | | | | | | | | | | QtConcurrent::run() The latter is in a module (QtConcurrent) that depends on QtCore. Don't make QtCore depend on QtConcurrent... The code doesn't use the QFuture returned from QtConcurrent::run(), anyway, so QThreadPool::start(function<void()>) is more than an adequate replacement. Task-number: QTBUG-109586 Pick-to: 6.5 6.4 6.2 Change-Id: Id00a42525c3d7454a1fa2d4812de634dbbea1035 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>