Release the local ref immediately

The local refs are released by the JVM when we exit the function, but if
we need tons of local refs, JVM will not be happy.

Fixes: QTBUG-81077
Change-Id: Ic38a5be1a563cb9c2465f9f902ff6ae6c61e698b
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
BogDan Vatra 2020-01-20 16:50:21 +02:00
parent 6c23f006e0
commit 3bbd21ccc4

View File

@ -146,7 +146,7 @@ public:
jobjectArray jFiles = static_cast<jobjectArray>(files.object()); jobjectArray jFiles = static_cast<jobjectArray>(files.object());
const jint nFiles = env->GetArrayLength(jFiles); const jint nFiles = env->GetArrayLength(jFiles);
for (int i = 0; i < nFiles; ++i) { for (int i = 0; i < nFiles; ++i) {
AssetItem item{QJNIObjectPrivate(env->GetObjectArrayElement(jFiles, i)).toString()}; AssetItem item{QJNIObjectPrivate::fromLocalRef(env->GetObjectArrayElement(jFiles, i)).toString()};
insert(std::upper_bound(begin(), end(), item, [](const auto &a, const auto &b){ insert(std::upper_bound(begin(), end(), item, [](const auto &a, const auto &b){
return a.name < b.name; return a.name < b.name;
}), item); }), item);