Make SmartLocalRef non-copyable
parent
2e831604e9
commit
b0148641e9
|
@ -20,8 +20,16 @@ class SmartLocalRef {
|
||||||
private:
|
private:
|
||||||
JNIEnv* mJniEnv;
|
JNIEnv* mJniEnv;
|
||||||
jobject& mJavaObj;
|
jobject& mJavaObj;
|
||||||
|
SmartLocalRef(const SmartLocalRef&); // non construction-copyable
|
||||||
|
SmartLocalRef& operator=(const SmartLocalRef&); // non copyable
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template<class T> SmartLocalRef(JNIEnv* env, T& object) : mJniEnv(env), mJavaObj((jobject&)object) {};
|
template<class T> SmartLocalRef(JNIEnv* env, T& object)
|
||||||
|
: mJniEnv(env)
|
||||||
|
, mJavaObj((jobject&)object)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
~SmartLocalRef() {
|
~SmartLocalRef() {
|
||||||
if (mJavaObj != NULL) {
|
if (mJavaObj != NULL) {
|
||||||
mJniEnv->DeleteLocalRef(mJavaObj);
|
mJniEnv->DeleteLocalRef(mJavaObj);
|
||||||
|
|
Loading…
Reference in New Issue