Kaydet (Commit) 78e217bc authored tarafından Tor Lillqvist's avatar Tor Lillqvist

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
üst 332fa134
...@@ -157,11 +157,30 @@ void AndroidSalInstance::RedrawWindows(ANativeWindow *pWindow, ANativeWindow_Buf ...@@ -157,11 +157,30 @@ void AndroidSalInstance::RedrawWindows(ANativeWindow *pWindow, ANativeWindow_Buf
void AndroidSalInstance::damaged(AndroidSalFrame */* frame */) 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 // Call the Java layer to post an invalidate if necessary
// static public void org.libreoffice.experimental.desktop.Desktop.callbackDamaged(); // static public void org.libreoffice.experimental.desktop.Desktop.callbackDamaged();
if (m_nDesktopClass != 0 && m_nCallbackDamaged != 0) if (nDesktopClass != 0 && nCallbackDamaged != 0)
m_pJNIEnv->CallStaticVoidMethod(m_nDesktopClass, m_nCallbackDamaged); m_pJNIEnv->CallStaticVoidMethod(nDesktopClass, nCallbackDamaged);
} }
void AndroidSalInstance::GetWorkArea( Rectangle& rRect ) void AndroidSalInstance::GetWorkArea( Rectangle& rRect )
...@@ -209,15 +228,6 @@ AndroidSalInstance::AndroidSalInstance( SalYieldMutex *pMutex ) ...@@ -209,15 +228,6 @@ AndroidSalInstance::AndroidSalInstance( SalYieldMutex *pMutex )
int res = (lo_get_javavm())->AttachCurrentThread(&m_pJNIEnv, NULL); int res = (lo_get_javavm())->AttachCurrentThread(&m_pJNIEnv, NULL);
LOGI("AttachCurrentThread res=%d env=%p", res, m_pJNIEnv); 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", LOGI("created Android Sal Instance thread: %d",
(int)pthread_self()); (int)pthread_self());
} }
......
...@@ -47,11 +47,6 @@ class AndroidSalInstance : public SvpSalInstance ...@@ -47,11 +47,6 @@ class AndroidSalInstance : public SvpSalInstance
// in which soffice_main() runs // in which soffice_main() runs
JNIEnv *m_pJNIEnv; JNIEnv *m_pJNIEnv;
// The Desktop class
jclass m_nDesktopClass;
jmethodID m_nCallbackDamaged;
public: public:
AndroidSalInstance( SalYieldMutex *pMutex ); AndroidSalInstance( SalYieldMutex *pMutex );
virtual ~AndroidSalInstance(); virtual ~AndroidSalInstance();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment