Android: Make more meticulous use of DeleteLocalRef

If we're in a function that isn't just going to immediately return to
Java, leaking local references can lead to problems eventually.
This commit is contained in:
JosJuice
2022-12-25 16:30:51 +01:00
parent 54a6c4a90d
commit 0b9351c194
3 changed files with 96 additions and 37 deletions

View File

@ -52,7 +52,9 @@ Java_org_dolphinemu_dolphinemu_model_GameFileCache_getAllGames(JNIEnv* env, jobj
env->NewObjectArray(static_cast<jsize>(ptr->GetSize()), IDCache::GetGameFileClass(), nullptr);
jsize i = 0;
GetPointer(env, obj)->ForEach([env, array, &i](const auto& game_file) {
env->SetObjectArrayElement(array, i++, GameFileToJava(env, game_file));
jobject j_game_file = GameFileToJava(env, game_file);
env->SetObjectArrayElement(array, i++, j_game_file);
env->DeleteLocalRef(j_game_file);
});
return array;
}