summaryrefslogtreecommitdiff
path: root/vcl/android
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-03-08 20:48:43 +0200
committerTor Lillqvist <tml@iki.fi>2013-03-08 20:51:59 +0200
commit78e217bcd039aa4dc3cf3eb41801d3b307941e4d (patch)
tree54fc0231ca0b68257b54bd962ee0853b3c5473e3 /vcl/android
parent332fa1344aaaf8ff190c594fe5829cf1551c5211 (diff)
Don't crash the other experimental apps
Don't try to find the class org.libreoffice.experimental.desktop.Desktop in the AndroidSalInstance constructor. It won't exist anyway except in that specific app. Look up the class in the damaged() method where it is needed. And actually, of course we should not hardcode the name of the app class like that, but the app should pass its class down to the native code. Change-Id: Ic15d5cc2c8d53be558711ca7a145d5489e34d298
Diffstat (limited to 'vcl/android')
-rw-r--r--vcl/android/androidinst.cxx32
1 files changed, 21 insertions, 11 deletions
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 89a8e684607f..9614d2b9d918 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -157,11 +157,30 @@ void AndroidSalInstance::RedrawWindows(ANativeWindow *pWindow, ANativeWindow_Buf
void AndroidSalInstance::damaged(AndroidSalFrame */* frame */)
{
+ static bool beenHere = false;
+ static jclass nDesktopClass = 0;
+ static jmethodID nCallbackDamaged = 0;
+
+ // Check if we are running in the experimental Desktop app
+ if (!beenHere) {
+ nDesktopClass = m_pJNIEnv->FindClass("org/libreoffice/experimental/desktop/Desktop");
+ if (nDesktopClass == 0) {
+ LOGI("Could not find Desktop class (this is normal if this isn't the \"desktop\" app)");
+ // We don't want the exception to kill the app
+ m_pJNIEnv->ExceptionClear();
+ } else {
+ nCallbackDamaged = m_pJNIEnv->GetStaticMethodID(nDesktopClass, "callbackDamaged", "()V");
+ if (nCallbackDamaged == 0)
+ LOGE("Could not find the callbackDamaged method");
+ }
+ beenHere = true;
+ }
+
// Call the Java layer to post an invalidate if necessary
// static public void org.libreoffice.experimental.desktop.Desktop.callbackDamaged();
- if (m_nDesktopClass != 0 && m_nCallbackDamaged != 0)
- m_pJNIEnv->CallStaticVoidMethod(m_nDesktopClass, m_nCallbackDamaged);
+ if (nDesktopClass != 0 && nCallbackDamaged != 0)
+ m_pJNIEnv->CallStaticVoidMethod(nDesktopClass, nCallbackDamaged);
}
void AndroidSalInstance::GetWorkArea( Rectangle& rRect )
@@ -209,15 +228,6 @@ AndroidSalInstance::AndroidSalInstance( SalYieldMutex *pMutex )
int res = (lo_get_javavm())->AttachCurrentThread(&m_pJNIEnv, NULL);
LOGI("AttachCurrentThread res=%d env=%p", res, m_pJNIEnv);
- m_nDesktopClass = m_pJNIEnv->FindClass("org/libreoffice/experimental/desktop/Desktop");
- if (m_nDesktopClass == 0)
- LOGE("Could not find Desktop class");
- else {
- m_nCallbackDamaged = m_pJNIEnv->GetStaticMethodID(m_nDesktopClass, "callbackDamaged", "()V");
- if (m_nCallbackDamaged == 0)
- LOGE("Could not find the callbackDamaged method");
- }
-
LOGI("created Android Sal Instance thread: %d",
(int)pthread_self());
}