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.

Pick-to: 6.9 6.8
Change-Id: I93be77ffc8750bb90fd7daed8c273169b03a29e4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Volker Hilsheimer 2025-01-03 12:08:44 +01:00
parent 403a47cfd5
commit fe6222b756

View File

@ -936,6 +936,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)) {
@ -951,6 +952,7 @@ auto QJniArrayBase::makeObjectArray(List &&list)
}
if (i)
env->PopLocalFrame(nullptr);
frame.hasFrame = false;
return ResultType(QJniObject::fromLocalRef(localArray));
}