Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c
index 172e832..b11d600 100644
--- a/firmware/target/hosted/android/lcd-android.c
+++ b/firmware/target/hosted/android/lcd-android.c
@@ -69,10 +69,6 @@ void connect_with_java(JNIEnv* env, jobject fb_instance)
         java_lcd_init        = e->GetMethodID(env, fb_class,
                                              "java_lcd_init",
                                              "(IILjava/nio/ByteBuffer;)V");
-                                               
-        native_buffer        = e->NewDirectByteBuffer(env,
-                                                  lcd_framebuffer,
-                                                  (jlong)sizeof(lcd_framebuffer));
         have_class           = true;
     }
     /* we need to setup parts for the java object every time */
@@ -118,8 +114,11 @@ Java_org_rockbox_RockboxFramebuffer_surfaceCreated(JNIEnv *env, jobject this,
     (void)surfaceholder;
     /* Update RockboxFramebuffer_instance */
     RockboxFramebuffer_instance = (*env)->NewGlobalRef(env, this);
+    native_buffer        = (*env)->NewDirectByteBuffer(env,
+                                              lcd_framebuffer,
+                                              (jlong)sizeof(lcd_framebuffer));
     /* possibly a new instance - reconnect */
-    connect_with_java(env, this);
+    connect_with_java(env, RockboxFramebuffer_instance);
     display_on = true;

     send_event(LCD_EVENT_ACTIVATION, NULL);
@@ -141,7 +140,9 @@ Java_org_rockbox_RockboxFramebuffer_surfaceDestroyed(JNIEnv *e, jobject this,
     display_on = false;

     (*e)->DeleteGlobalRef(e, RockboxFramebuffer_instance);
+    (*e)->DeleteGlobalRef(e, native_buffer);
     RockboxFramebuffer_instance = NULL;
+    native_buffer = NULL;
 }

 bool lcd_active(void)