Beispiel #1
0
CXXContext::~CXXContext()
{
	JNIContext *jniContext = JNIContext::sharedInstance();

	ectx_method_createProxiedCallback = 0;

	if (ectx_class != 0)
	{
		jniContext->deleteGlobalRef(ectx_class);
		ectx_class = 0;
	}

	if (ectx_object != 0)
	{
		jniContext->deleteGlobalRef(ectx_object);
		ectx_object = 0;
	}

	if (actx_object != 0)
	{
		jniContext->deleteGlobalRef(actx_object);
		actx_object = 0;
	}

	sm_sharedInstance = 0;
}
Beispiel #2
0
void CXXContext::deregisterProxyComponent(long contextAddress)
{
	LOGV("deregisterProxyComponent contextAddress %ld", contextAddress);
	JNIContext *jniContext = JNIContext::sharedInstance();
	pthread_mutex_lock(&proxyComponentMapMutex);
	proxyComponentMap[contextAddress] = 0;
	std::map<long,jobject>::const_iterator iter;
	for (iter = proxyComponentMap.begin(); iter != proxyComponentMap.end(); iter++)
	{
		if ((*iter).first == contextAddress)
		{
			jobject externalObject = (jobject) (*iter).second;
			LOGV("deregisterProxyComponent erasing contextAddress %ld", contextAddress);
			proxyComponentMap.erase(contextAddress);
			proxyComponentRefCountMap[externalObject]--;
			if (proxyComponentRefCountMap[externalObject] <= 0)
			{
				proxyComponentRefCountMap.erase(externalObject);
				jniContext->deleteGlobalRef(externalObject);
			}
			break;
		}
	}
	pthread_mutex_unlock(&proxyComponentMapMutex);
}
Beispiel #3
0
void CXXContext::setAndroidContext(jobject applicationContext)
{
	LOGV("setApplicationContext applicationContext %ld", (long) applicationContext);
	JNIContext *jniContext = JNIContext::sharedInstance();
	jniContext->deleteGlobalRef(actx_object);
	actx_object = jniContext->localToGlobalRef(applicationContext);
	LOGV("updated actx_object %ld", (long) actx_object);
}
Beispiel #4
0
bool CXXContext::deleteProxyComponent(jobject externalObject)
{
	LOGV("deleteProxyComponent externalObject %ld", (long) externalObject);
	JNIContext *jni = JNIContext::sharedInstance();
	bool success = false;
	jni->pushLocalFrame();
	if (jni->newLocalRef(externalObject) != 0)
	{
		jobject globalRef = jni->newGlobalRef(externalObject);
		jni->deleteGlobalRef(globalRef);
		success = true;
	}
	jni->popLocalFrame();
	return success;
}