Android: Call update touch pointer from thread.
Fixes crash in single core when attaching the JVM
This commit is contained in:
parent
4cd5667319
commit
3cc10dcaf9
|
@ -72,6 +72,22 @@ Common::Event s_update_main_frame_event;
|
||||||
bool s_have_wm_user_stop = false;
|
bool s_have_wm_user_stop = false;
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
|
void UpdatePointer()
|
||||||
|
{
|
||||||
|
// Update touch pointer
|
||||||
|
JNIEnv* env;
|
||||||
|
int get_env_status =
|
||||||
|
IDCache::GetJavaVM()->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
|
||||||
|
|
||||||
|
if (get_env_status == JNI_EDETACHED)
|
||||||
|
IDCache::GetJavaVM()->AttachCurrentThread(&env, nullptr);
|
||||||
|
|
||||||
|
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetUpdateTouchPointer());
|
||||||
|
|
||||||
|
if (get_env_status == JNI_EDETACHED)
|
||||||
|
IDCache::GetJavaVM()->DetachCurrentThread();
|
||||||
|
}
|
||||||
|
|
||||||
void Host_NotifyMapLoaded()
|
void Host_NotifyMapLoaded()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -108,11 +124,8 @@ void Host_UpdateMainFrame()
|
||||||
|
|
||||||
void Host_RequestRenderWindowSize(int width, int height)
|
void Host_RequestRenderWindowSize(int width, int height)
|
||||||
{
|
{
|
||||||
// Update touch pointer
|
std::thread jnicall(UpdatePointer);
|
||||||
JNIEnv* env;
|
jnicall.join();
|
||||||
IDCache::GetJavaVM()->AttachCurrentThread(&env, nullptr);
|
|
||||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetUpdateTouchPointer());
|
|
||||||
IDCache::GetJavaVM()->DetachCurrentThread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Host_UINeedsControllerState()
|
bool Host_UINeedsControllerState()
|
||||||
|
|
Loading…
Reference in New Issue