diff options
author | Christian Strømme <christian.stromme@theqtcompany.com> | 2015-02-03 17:43:02 +0100 |
---|---|---|
committer | Christian Stromme <christian.stromme@theqtcompany.com> | 2015-02-26 13:02:27 +0000 |
commit | c8d64cbcc6728e8862cc16bb1d007349fd7012b4 (patch) | |
tree | d7d665c1b7b0c70873ff594494985a092a88b37d /src/corelib/kernel/qjni.cpp | |
parent | cb27388eb06335ce50bf599e5fc15b2d2c9a543a (diff) |
Android: Add scoped local ref. handler.
Adds an internal class for handling local jni references. When calling
raw jni functions the returned object is usually a local reference, to
avoid overflowing the local reference table we need to free any local
ref. as soon as we're done with them. The class QJNIScopedLocalRef,
a QScopedPointer, makes this process a lot easier.
Change-Id: I093e5671f0dcd254d5c2c7985c8c0f625d5592a4
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src/corelib/kernel/qjni.cpp')
-rw-r--r-- | src/corelib/kernel/qjni.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 694463b9d8..2290a74c31 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -204,6 +204,15 @@ static jfieldID getCachedFieldID(JNIEnv *env, } } +void QJNILocalRefDeleter::cleanup(jobject obj) +{ + if (obj == 0) + return; + + QJNIEnvironmentPrivate env; + env->DeleteLocalRef(obj); +} + class QJNIEnvironmentPrivateTLS { public: @@ -2258,4 +2267,3 @@ bool QJNIObjectPrivate::isSameObject(const QJNIObjectPrivate &other) const } QT_END_NAMESPACE - |