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>bb10
parent
d51a47c316
commit
77e00a4d08
|
|
@ -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>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue