mirror of https://github.com/encounter/SDL.git
Fixed bug #5118 - [Android] PointerIcon leak in Cursor API
This commit is contained in:
parent
5ca0926d8d
commit
a1e992b110
|
@ -1479,6 +1479,19 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||
return mLastCursorID;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void destroyCustomCursor(int cursorID) {
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
try {
|
||||
mCursors.remove(cursorID);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
|
|
|
@ -303,6 +303,7 @@ static jmethodID midClipboardGetText;
|
|||
static jmethodID midClipboardHasText;
|
||||
static jmethodID midClipboardSetText;
|
||||
static jmethodID midCreateCustomCursor;
|
||||
static jmethodID midDestroyCustomCursor;
|
||||
static jmethodID midGetContext;
|
||||
static jmethodID midGetDisplayDPI;
|
||||
static jmethodID midGetManifestEnvironmentVariables;
|
||||
|
@ -582,6 +583,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
|||
midClipboardHasText = (*env)->GetStaticMethodID(env, mActivityClass, "clipboardHasText", "()Z");
|
||||
midClipboardSetText = (*env)->GetStaticMethodID(env, mActivityClass, "clipboardSetText", "(Ljava/lang/String;)V");
|
||||
midCreateCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "createCustomCursor", "([IIIII)I");
|
||||
midDestroyCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "destroyCustomCursor", "(I)V");
|
||||
midGetContext = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;");
|
||||
midGetDisplayDPI = (*env)->GetStaticMethodID(env, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
|
||||
midGetManifestEnvironmentVariables = (*env)->GetStaticMethodID(env, mActivityClass, "getManifestEnvironmentVariables", "()Z");
|
||||
|
@ -612,6 +614,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
|||
!midClipboardHasText ||
|
||||
!midClipboardSetText ||
|
||||
!midCreateCustomCursor ||
|
||||
!midDestroyCustomCursor ||
|
||||
!midGetContext ||
|
||||
!midGetDisplayDPI ||
|
||||
!midGetManifestEnvironmentVariables ||
|
||||
|
@ -2503,6 +2506,12 @@ int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y)
|
|||
return custom_cursor;
|
||||
}
|
||||
|
||||
void Android_JNI_DestroyCustomCursor(int cursorID)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
(*env)->CallStaticVoidMethod(env, mActivityClass, midDestroyCustomCursor, cursorID);
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_bool Android_JNI_SetCustomCursor(int cursorID)
|
||||
{
|
||||
|
|
|
@ -118,6 +118,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
|
|||
|
||||
/* Cursor support */
|
||||
int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y);
|
||||
void Android_JNI_DestroyCustomCursor(int cursorID);
|
||||
SDL_bool Android_JNI_SetCustomCursor(int cursorID);
|
||||
SDL_bool Android_JNI_SetSystemCursor(int cursorID);
|
||||
|
||||
|
|
|
@ -113,6 +113,10 @@ Android_CreateSystemCursor(SDL_SystemCursor id)
|
|||
static void
|
||||
Android_FreeCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
SDL_AndroidCursorData *data = (SDL_AndroidCursorData*) cursor->driverdata;
|
||||
if (data->custom_cursor != 0) {
|
||||
Android_JNI_DestroyCustomCursor(data->custom_cursor);
|
||||
}
|
||||
SDL_free(cursor->driverdata);
|
||||
SDL_free(cursor);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue