mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Android: on rare occasion, prevent Android_JNI_GetNativeWindow() from crashing
If Java getNativeSurface() returns null, then ANativeWindow_fromSurface() would crash().
This commit is contained in:
parent
1e22fc1513
commit
03b0e1dee0
@ -951,13 +951,15 @@ static void LocalReferenceHolder_Cleanup(struct LocalReferenceHolder *refholder)
|
|||||||
|
|
||||||
ANativeWindow* Android_JNI_GetNativeWindow(void)
|
ANativeWindow* Android_JNI_GetNativeWindow(void)
|
||||||
{
|
{
|
||||||
ANativeWindow* anw;
|
ANativeWindow *anw = NULL;
|
||||||
jobject s;
|
jobject s;
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
|
|
||||||
s = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetNativeSurface);
|
s = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetNativeSurface);
|
||||||
anw = ANativeWindow_fromSurface(env, s);
|
if (s) {
|
||||||
(*env)->DeleteLocalRef(env, s);
|
anw = ANativeWindow_fromSurface(env, s);
|
||||||
|
(*env)->DeleteLocalRef(env, s);
|
||||||
|
}
|
||||||
|
|
||||||
return anw;
|
return anw;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user