mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 02:26:16 +00:00
external/jnipp: Check and re-assign JNIEnv
Fixes a crash when resumed from launcher. Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2226>
This commit is contained in:
parent
5b8edfbb30
commit
cdb9c38ee0
|
@ -1 +1,4 @@
|
|||
jnipp: Update to fix issues including CTS crashes.
|
||||
---
|
||||
- mr.2226
|
||||
---
|
||||
jnipp: Update/patch to fix issues, including crashes.
|
||||
|
|
13
src/external/jnipp/jnipp.cpp
vendored
13
src/external/jnipp/jnipp.cpp
vendored
|
@ -156,11 +156,22 @@ namespace jni
|
|||
|
||||
#endif // _WIN32
|
||||
|
||||
static bool isEnvChanged(JavaVM* vm, ScopedEnv& threadLocalEnv) {
|
||||
if (vm == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
JNIEnv *curEnv = nullptr;
|
||||
getEnv(vm, &curEnv);
|
||||
return curEnv != threadLocalEnv.get();
|
||||
}
|
||||
|
||||
|
||||
JNIEnv* env()
|
||||
{
|
||||
static thread_local ScopedEnv env;
|
||||
|
||||
if (env.get() != nullptr && !isAttached(javaVm))
|
||||
if (env.get() != nullptr && (!isAttached(javaVm) || isEnvChanged(javaVm, env)))
|
||||
{
|
||||
// we got detached, so clear it.
|
||||
// will be re-populated from static javaVm below.
|
||||
|
|
Loading…
Reference in a new issue