Windows: don't cache the JNIEnv pointer in the message handle, but acquire it through the global JavaVM handle.
This commit is contained in:
parent
af9e73ed11
commit
67957781a2
|
@ -301,6 +301,12 @@ JavaVM *getJVM() {
|
||||||
return jvm;
|
return jvm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEnv *getThreadEnv() {
|
||||||
|
JNIEnv *env;
|
||||||
|
(*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_4);
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||||
jvm = vm;
|
jvm = vm;
|
||||||
return JNI_VERSION_1_4;
|
return JNI_VERSION_1_4;
|
||||||
|
|
|
@ -122,6 +122,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern JavaVM *getJVM();
|
extern JavaVM *getJVM();
|
||||||
|
extern JNIEnv *getThreadEnv();
|
||||||
extern void initAttribList(attrib_list_t *list);
|
extern void initAttribList(attrib_list_t *list);
|
||||||
extern void putAttrib(attrib_list_t *list, int attrib);
|
extern void putAttrib(attrib_list_t *list, int attrib);
|
||||||
|
|
||||||
|
|
|
@ -87,11 +87,10 @@ static LRESULT CALLBACK lwjglWindowProc(HWND hWnd,
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
JNIEnv *env;
|
|
||||||
jclass display_class;
|
jclass display_class;
|
||||||
jmethodID handleMessage_method;
|
jmethodID handleMessage_method;
|
||||||
LONG message_time;
|
LONG message_time;
|
||||||
env = (JNIEnv *)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
JNIEnv *env = getThreadEnv();
|
||||||
if (env != NULL && !(*env)->ExceptionOccurred(env)) {
|
if (env != NULL && !(*env)->ExceptionOccurred(env)) {
|
||||||
display_class = (*env)->FindClass(env, "org/lwjgl/opengl/Win32Display");
|
display_class = (*env)->FindClass(env, "org/lwjgl/opengl/Win32Display");
|
||||||
if (display_class != NULL) {
|
if (display_class != NULL) {
|
||||||
|
@ -186,7 +185,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nCreateWindow(JNIEnv *
|
||||||
throwException(env, "Failed to create the window.");
|
throwException(env, "Failed to create the window.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetWindowLongPtr(display_hwnd, GWLP_USERDATA, (LONG_PTR)env);
|
|
||||||
display_hdc = GetDC(display_hwnd);
|
display_hdc = GetDC(display_hwnd);
|
||||||
ShowWindow(display_hwnd, SW_SHOWDEFAULT);
|
ShowWindow(display_hwnd, SW_SHOWDEFAULT);
|
||||||
UpdateWindow(display_hwnd);
|
UpdateWindow(display_hwnd);
|
||||||
|
|
Loading…
Reference in New Issue