JNI: fix JNI warning from local reference mixup

When making an object array, we use a LocalFrame to get access to the
conversion routine, but manage the frame of local references manually in
chunks of 100 objects. If any of the conversion routines uses the
LocalFrame's implicit frame management, then we push and pop frames out
of order.

Disable the frame's implicit frame management, and only use our chunk
management.

Amends 37638c84efaf2810ad49da0b987f19287d8c4ad6.

Change-Id: I93be77ffc8750bb90fd7daed8c273169b03a29e4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit fe6222b7561faa52f12a961d7c5417e364cf0236)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 6a6ce2474e6b6c24dadf8ed2b007c7b3000cf6da)
This commit is contained in:
Volker Hilsheimer 2025-01-03 12:08:44 +01:00 committed by Qt Cherry-pick Bot
parent 5fffbba133
commit d89bc3c7aa

View File

@ -631,6 +631,7 @@ auto QJniArrayBase::makeObjectArray(List &&list)
// explicitly manage the frame for local references in chunks of 100
QJniObject::LocalFrame frame(env);
frame.hasFrame = true;
constexpr jint frameCapacity = 100;
qsizetype i = 0;
for (const auto &element : std::as_const(list)) {
@ -646,6 +647,7 @@ auto QJniArrayBase::makeObjectArray(List &&list)
}
if (i)
env->PopLocalFrame(nullptr);
frame.hasFrame = false;
return ResultType(QJniObject::fromLocalRef(localArray));
}