From 8dd75128a5a7e068ae63f3d1cc6b41410f7d7122 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 18 Jun 2012 22:02:57 +0300 Subject: ByteBufferWrapper tweaks operator() gets called in a Java GC thread. A JNIEnv* saved in the constructor (which is called from the UI thread) is not valid in other threads (although for now, Dalvik notices, warns, and works around it). So don't bother keeping the JNIEnv*. Instead fetch one when needed. Move the method implementations from inline in the header to libotouch's android.cxx. Change-Id: I7de6fc54bb8d9a59146576d6e8c325fe917393ee --- sal/inc/sal/ByteBufferWrapper.hxx | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'sal/inc') diff --git a/sal/inc/sal/ByteBufferWrapper.hxx b/sal/inc/sal/ByteBufferWrapper.hxx index 954922d65b16..63bb618278d6 100644 --- a/sal/inc/sal/ByteBufferWrapper.hxx +++ b/sal/inc/sal/ByteBufferWrapper.hxx @@ -21,25 +21,14 @@ namespace org { namespace libreoffice { namespace touch { class ByteBufferWrapper { private: - JNIEnv *env; - jobject object; + jobject object; public: - ByteBufferWrapper(JNIEnv *e, jobject o) : - env(e) - { - object = env->NewGlobalRef(o); - } - - sal_uInt8* pointer() - { - return (sal_uInt8 *) env->GetDirectBufferAddress(object); - } - - void operator()(sal_uInt8 * /* p */) - { - env->DeleteGlobalRef(object); - } + ByteBufferWrapper(JNIEnv *env, jobject o); + + sal_uInt8* pointer(); + + void operator()(sal_uInt8 *p); }; }; }; }; -- cgit