src/core/android/SDL_android.cpp
changeset 6308 263e2c049c22
parent 6307 6048116f40b1
child 6330 0fa55ca2efdd
     1.1 --- a/src/core/android/SDL_android.cpp	Fri May 25 15:10:13 2012 -0300
     1.2 +++ b/src/core/android/SDL_android.cpp	Fri May 25 15:35:41 2012 -0300
     1.3 @@ -442,7 +442,7 @@
     1.4          goto failure;
     1.5      }
     1.6  
     1.7 -    fileNameJString = (jstring)ctx->hidden.androidio.fileName;
     1.8 +    fileNameJString = (jstring)ctx->hidden.androidio.fileNameRef;
     1.9  
    1.10      // context = SDLActivity.getContext();
    1.11      mid = mEnv->GetStaticMethodID(mActivityClass,
    1.12 @@ -462,7 +462,6 @@
    1.13          goto failure;
    1.14      }
    1.15  
    1.16 -    ctx->hidden.androidio.inputStream = inputStream;
    1.17      ctx->hidden.androidio.inputStreamRef = mEnv->NewGlobalRef(inputStream);
    1.18  
    1.19      // Despite all the visible documentation on [Asset]InputStream claiming
    1.20 @@ -490,7 +489,6 @@
    1.21          goto failure;
    1.22      }
    1.23  
    1.24 -    ctx->hidden.androidio.readableByteChannel = readableByteChannel;
    1.25      ctx->hidden.androidio.readableByteChannelRef =
    1.26          mEnv->NewGlobalRef(readableByteChannel);
    1.27  
    1.28 @@ -510,6 +508,11 @@
    1.29          if(ctx->hidden.androidio.inputStreamRef != NULL) {
    1.30              mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.inputStreamRef);
    1.31          }
    1.32 +
    1.33 +        if(ctx->hidden.androidio.readableByteChannelRef != NULL) {
    1.34 +            mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.readableByteChannelRef);
    1.35 +        }
    1.36 +
    1.37      }
    1.38  
    1.39      return result;
    1.40 @@ -529,7 +532,6 @@
    1.41      }
    1.42  
    1.43      jstring fileNameJString = mEnv->NewStringUTF(fileName);
    1.44 -    ctx->hidden.androidio.fileName = fileNameJString;
    1.45      ctx->hidden.androidio.fileNameRef = mEnv->NewGlobalRef(fileNameJString);
    1.46      ctx->hidden.androidio.inputStreamRef = NULL;
    1.47  
    1.48 @@ -547,7 +549,7 @@
    1.49          return -1;
    1.50      }
    1.51  
    1.52 -    jobject readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannel;
    1.53 +    jobject readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannelRef;
    1.54      jmethodID readMethod = (jmethodID)ctx->hidden.androidio.readMethod;
    1.55      jobject byteBuffer = mEnv->NewDirectByteBuffer(buffer, bytesRemaining);
    1.56  
    1.57 @@ -593,7 +595,7 @@
    1.58              mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.fileNameRef);
    1.59          }
    1.60  
    1.61 -        jobject inputStream = (jobject)ctx->hidden.androidio.inputStream;
    1.62 +        jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef;
    1.63  
    1.64          // inputStream.close();
    1.65          jmethodID mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream),
    1.66 @@ -640,7 +642,7 @@
    1.67      }
    1.68  
    1.69      long movement = newPosition - ctx->hidden.androidio.position;
    1.70 -    jobject inputStream = (jobject)ctx->hidden.androidio.inputStream;
    1.71 +    jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef;
    1.72  
    1.73      if (movement > 0) {
    1.74          unsigned char buffer[1024];