lib/android: pin the App instance being registered in C
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 20 Jan 2015 19:25:26 +0000 (14:25 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 26 Jan 2015 01:54:47 +0000 (20:54 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/android/native_app_glue.nit

index fc5a19f..af3c797 100644 (file)
@@ -301,7 +301,10 @@ extern class NativeAppGlue `{ struct android_app* `}
        # We use the `userData` field of the C structure to store an handle to
        # the associated App
        private fun user_data: App `{ return recv->userData; `}
-       private fun user_data=(val: App) `{ recv->userData = val; `}
+       private fun user_data=(val: App) `{
+               App_incr_ref(val);
+               recv->userData = val;
+       `}
 
        # Fill this in with the function to process input events.  At this point
        # the event has already been pre-dispatched, and it will be finished upon