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 committed 2022-12-27 22:03:44 +01:00
1 parent 54a6c4a90d
commit 0b9351c194
3 files changed
+96 -37

No files matched your search

@@ -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;
}