diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2024-02-01 10:05:59 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2024-02-22 20:43:50 +0100 |
commit | 77e00a4d08498285ea4273e01fda489ae6a7fd8a (patch) | |
tree | 5276d6f0c36eb5d9572386a09f62eaf18a24acee /src/corelib/kernel | |
parent | d51a47c316dcaf65f9cb82babc9ccfcd5ba62310 (diff) |
JNI: Support declared QtJniTypes in QJniArray
They can be treated like QJniObject, but are not QJniObject instances.
Pick-to: 6.7
Change-Id: I419b6d0493f9a0ad3dcc726d48ac4c9ad3e6bc19
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qjniarray.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/corelib/kernel/qjniarray.h b/src/corelib/kernel/qjniarray.h index 16c02e087d..f2f4dba92e 100644 --- a/src/corelib/kernel/qjniarray.h +++ b/src/corelib/kernel/qjniarray.h @@ -126,7 +126,9 @@ public: using ElementType = typename std::remove_reference_t<Container>::value_type; if constexpr (std::disjunction_v<std::is_same<ElementType, jobject>, - std::is_same<ElementType, QJniObject>>) { + std::is_same<ElementType, QJniObject>, + std::is_base_of<QtJniTypes::JObjectBase, ElementType> + >) { return makeObjectArray(std::forward<Container>(container)); } else if constexpr (std::is_same_v<ElementType, jfloat>) { return makeArray<jfloat>(std::forward<Container>(container), &JNIEnv::NewFloatArray, @@ -370,10 +372,12 @@ auto QJniArrayBase::makeObjectArray(List &&list) // this assumes that all objects in the list have the same class jclass elementClass = nullptr; - if constexpr (std::is_same_v<ElementType, QJniObject>) + if constexpr (std::disjunction_v<std::is_same<ElementType, QJniObject>, + std::is_base_of<QtJniTypes::JObjectBase, ElementType>>) { elementClass = list.first().objectClass(); - else + } else { elementClass = env->GetObjectClass(list.first()); + } auto localArray = env->NewObjectArray(length, elementClass, nullptr); if (QJniEnvironment::checkAndClearExceptions(env)) return QJniArray<jobject>(); |