From fe6222b7561faa52f12a961d7c5417e364cf0236 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 3 Jan 2025 12:08:44 +0100 Subject: [PATCH] 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 --- src/corelib/kernel/qjniarray.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/kernel/qjniarray.h b/src/corelib/kernel/qjniarray.h index 8a4af8775e8..d93353964ca 100644 --- a/src/corelib/kernel/qjniarray.h +++ b/src/corelib/kernel/qjniarray.h @@ -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)); }