QJniArray: find the java/lang/String class from the cache
Don't look it up through JNIEnv::FindString, use our internal cache. For that (and as we don't want to instantiate a temporary QJniEnvironment) we need to use the QtAndroidPrivate internal symbol, which then needs to be forward declared. Change-Id: I4a69bf973fbdc1df6939f5ce94878588a4fcbd3d Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Soheil Armin <soheil.armin@qt.io>
This commit is contained in:
parent
4de9b94042
commit
1a2ffdc9b6
@ -24,6 +24,12 @@ QT_BEGIN_NAMESPACE
|
|||||||
template <typename T> class QJniArray;
|
template <typename T> class QJniArray;
|
||||||
template <typename T> struct QJniArrayMutableIterator;
|
template <typename T> struct QJniArrayMutableIterator;
|
||||||
|
|
||||||
|
// forward declare here so that we don't have to include the private header
|
||||||
|
namespace QtAndroidPrivate
|
||||||
|
{
|
||||||
|
Q_CORE_EXPORT jclass findClass(const char *className, JNIEnv *env);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct QJniArrayIterator
|
struct QJniArrayIterator
|
||||||
{
|
{
|
||||||
@ -915,7 +921,7 @@ auto QJniArrayBase::makeObjectArray(List &&list)
|
|||||||
std::is_base_of<QtJniTypes::JObjectBase, ElementType>>) {
|
std::is_base_of<QtJniTypes::JObjectBase, ElementType>>) {
|
||||||
elementClass = std::begin(list)->objectClass();
|
elementClass = std::begin(list)->objectClass();
|
||||||
} else if constexpr (std::is_same_v<ElementType, QString>) {
|
} else if constexpr (std::is_same_v<ElementType, QString>) {
|
||||||
elementClass = env->FindClass("java/lang/String");
|
elementClass = QtAndroidPrivate::findClass("java/lang/String", env);
|
||||||
} else {
|
} else {
|
||||||
elementClass = env->GetObjectClass(*std::begin(list));
|
elementClass = env->GetObjectClass(*std::begin(list));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user