diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2021-05-17 15:12:30 +0300 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2021-05-20 09:26:42 +0000 |
commit | df022972b0860400449e3a6dabab63ea4e4656ac (patch) | |
tree | 0d225e6d7fd54888491284f3a90b4374d3fcbd9c /src/corelib/kernel/qcoreapplication.cpp | |
parent | 6fcc272ac9dcf1d6d65de1bdf3138722ba63a902 (diff) |
Don't throw an exception on platforms with no permission API
Using the permission API without guards for Android cause exception
on all other platforms, instead we can print a warning with the same
message if QT_DEBUG is defined to also make it less confusing for other
platforms.
Also, return QPermission::Authorized by default for platforms with no
implementation to this API.
Change-Id: Ie01a6a7f8b6a066685d32c861a56e9ded2c06410
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index bb874569ab..0cb7f30644 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -3085,14 +3085,11 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc QPromise<QPermission::PermissionResult> promise; QFuture<QPermission::PermissionResult> future = promise.future(); promise.start(); - #ifndef QT_NO_EXCEPTIONS - const auto exception = std::make_exception_ptr( - std::runtime_error("This platform doesn't have an implementation " - "for the application permissions API.")); - promise.setException(exception); - #else - promise.addResult(QPermission::Denied); - #endif +#if defined(QT_DEBUG) + qWarning() << "This platform doesn't have an implementation" + << "for the application permissions API."; +#endif + promise.addResult(QPermission::Authorized); promise.finish(); return future; } @@ -3144,6 +3141,10 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc \snippet permissions/permissions.cpp Request camera permission sync + \note Any platform that doesn't have an implementation for this API, + returns QPermission::Authorized by default. Currently, only Android + has an implemtation for this API. + \since 6.2 \sa checkPermission() */ @@ -3172,6 +3173,10 @@ QCoreApplication::requestPermission(QPermission::PermisionType permission) \snippet permissions/permissions.cpp Request camera permission sync on Android + \note Any platform that doesn't have an implementation for this API, + returns QPermission::Authorized by default. Currently, only Android + has an implemtation for this API. + \since 6.2 \sa checkPermission() */ @@ -3194,6 +3199,10 @@ QCoreApplication::requestPermission(const QString &permission) \snippet permissions/permissions.cpp Check camera permission sync + \note Any platform that doesn't have an implementation for this API, + returns QPermission::Authorized by default. Currently, only Android + has an implemtation for this API. + \since 6.2 \sa requestPermission() */ @@ -3217,6 +3226,10 @@ QCoreApplication::checkPermission(QPermission::PermisionType permission) \snippet permissions/permissions.cpp Check camera permission sync on Android + \note Any platform that doesn't have an implementation for this API, + returns QPermission::Authorized by default. Currently, only Android + has an implemtation for this API. + \since 6.2 \sa requestPermission() */ |