Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into iss2905-adjust_folder

This commit is contained in:
minggo 2013-10-10 15:07:04 +08:00
commit 28b06ecde0
5 changed files with 21 additions and 8 deletions

View File

@ -8,11 +8,14 @@ cocos2d-x-3.0alpha1 @??? 2013
[Android] [Android]
[FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes
[NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again [NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again
[FIX] Fixed application will crash when pause and resume.
[Mac] [Mac]
[FIX] Removed unused CCLOG() from GL initialization [FIX] Removed unused CCLOG() from GL initialization
[Javascript binding] [Javascript binding]
[FIX] Fixed a memory leak in ScriptingCore::runScript() [FIX] Fixed a memory leak in ScriptingCore::runScript()
[FIX] sys.localStorage.getItem() does not support non-ascii string. [FIX] sys.localStorage.getItem() does not support non-ascii string.
[Lua Binding]
[NEW] Added Armature lua binding and added test samples.
cocos2d-x-3.0alpha0 @Sep.19 2013 cocos2d-x-3.0alpha0 @Sep.19 2013
[all platforms] [all platforms]

View File

@ -58,6 +58,8 @@ namespace cocos2d {
jobject JniHelper::classloader = NULL; jobject JniHelper::classloader = NULL;
JNIEnv* JniHelper::env = NULL; JNIEnv* JniHelper::env = NULL;
static pthread_key_t s_threadKey;
JavaVM* JniHelper::getJavaVM() { JavaVM* JniHelper::getJavaVM() {
pthread_t thisthread = pthread_self(); pthread_t thisthread = pthread_self();
LOGD("JniHelper::getJavaVM(), pthread_self() = %X", thisthread); LOGD("JniHelper::getJavaVM(), pthread_self() = %X", thisthread);
@ -72,6 +74,10 @@ namespace cocos2d {
JniHelper::cacheEnv(javaVM); JniHelper::cacheEnv(javaVM);
} }
void JniHelper::detach_current_thread (void *env) {
_psJavaVM->DetachCurrentThread();
}
bool JniHelper::cacheEnv(JavaVM* jvm) { bool JniHelper::cacheEnv(JavaVM* jvm) {
JNIEnv* _env = NULL; JNIEnv* _env = NULL;
// get jni environment // get jni environment
@ -89,7 +95,8 @@ namespace cocos2d {
// TODO : If calling AttachCurrentThread() on a native thread // TODO : If calling AttachCurrentThread() on a native thread
// must call DetachCurrentThread() in future. // must call DetachCurrentThread() in future.
// see: http://developer.android.com/guide/practices/design/jni.html // see: http://developer.android.com/guide/practices/design/jni.html
pthread_key_create (&s_threadKey, JniHelper::detach_current_thread);
if (jvm->AttachCurrentThread(&_env, NULL) < 0) if (jvm->AttachCurrentThread(&_env, NULL) < 0)
{ {
LOGD("Failed to get the environment using AttachCurrentThread()"); LOGD("Failed to get the environment using AttachCurrentThread()");
@ -99,6 +106,8 @@ namespace cocos2d {
} else { } else {
// Success : Attached and obtained JNIEnv! // Success : Attached and obtained JNIEnv!
JniHelper::env = _env; JniHelper::env = _env;
if (pthread_getspecific(s_threadKey) == NULL)
pthread_setspecific(s_threadKey, _env);
return true; return true;
} }

View File

@ -60,6 +60,7 @@ public:
static jobject classloader; static jobject classloader;
private: private:
static void detach_current_thread (void *env);
static bool cacheEnv(JavaVM* jvm); static bool cacheEnv(JavaVM* jvm);
static bool getMethodInfo_DefaultClassLoader(JniMethodInfo &methodinfo, static bool getMethodInfo_DefaultClassLoader(JniMethodInfo &methodinfo,

View File

@ -215,19 +215,19 @@ static cocos_dimensions engine_init_display(struct engine* engine) {
/** /**
* Invoke the dispatching of the next bunch of Runnables in the Java-Land * Invoke the dispatching of the next bunch of Runnables in the Java-Land
*/ */
static bool s_methodInitialized = false;
static void dispatch_pending_runnables() { static void dispatch_pending_runnables() {
static cocos2d::JniMethodInfo info; static cocos2d::JniMethodInfo info;
static bool initialized = false;
if (!s_methodInitialized) {
if (!initialized) { s_methodInitialized = cocos2d::JniHelper::getStaticMethodInfo(
initialized = cocos2d::JniHelper::getStaticMethodInfo(
info, info,
"org/cocos2dx/lib/Cocos2dxHelper", "org/cocos2dx/lib/Cocos2dxHelper",
"dispatchPendingRunnables", "dispatchPendingRunnables",
"()V" "()V"
); );
if (!initialized) { if (!s_methodInitialized) {
LOGW("Unable to dispatch pending Runnables!"); LOGW("Unable to dispatch pending Runnables!");
return; return;
} }
@ -652,7 +652,7 @@ void android_main(struct android_app* state) {
engine_term_display(&engine); engine_term_display(&engine);
memset(&engine, 0, sizeof(engine)); memset(&engine, 0, sizeof(engine));
s_methodInitialized = false;
return; return;
} }
} }

@ -1 +1 @@
Subproject commit ec90d1c35d06c1de3cb5079f885c22c45b8f129b Subproject commit 6f5bc7bbd036c76e7c6be121573662099997a0a4