[Libreoffice-commits] core.git: 2 commits - vcl/android vcl/inc

Tor Lillqvist tml at iki.fi
Fri Mar 8 11:26:25 PST 2013


 vcl/android/androidinst.cxx     |   38 +++++++++++++++++++++-----------------
 vcl/inc/android/androidinst.hxx |    6 ------
 2 files changed, 21 insertions(+), 23 deletions(-)

New commits:
commit 54e458f691e55d321ba3e4e4cc7e00b9b3c09489
Author: Tor Lillqvist <tml at iki.fi>
Date:   Fri Mar 8 21:06:14 2013 +0200

    AndroidSalInstance::Wakeup() is unused
    
    The Wakeup() in the base class, SvpSalInstance, is not virtual. So this
    Wakeup() does not override the Wakeup() in the base class, as the author maybe
    thought. I don't see in git history that it would have ever been called
    explicitly on any AndroidSalInstance objects either. Or am I missing
    something?
    
    Change-Id: I932398e7c0a37a3048c5d372996fe6ac6f209887

diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 9614d2b..89a6cbd 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -237,12 +237,6 @@ AndroidSalInstance::~AndroidSalInstance()
     LOGI("destroyed Android Sal Instance");
 }
 
-void AndroidSalInstance::Wakeup()
-{
-    LOGI("Wakeup alooper");
-    LOGI("busted - no global looper");
-}
-
 bool AndroidSalInstance::AnyInput( sal_uInt16 nType )
 {
     if( (nType & VCL_INPUT_TIMER) != 0 )
diff --git a/vcl/inc/android/androidinst.hxx b/vcl/inc/android/androidinst.hxx
index 22800f0..f2f0a2e 100644
--- a/vcl/inc/android/androidinst.hxx
+++ b/vcl/inc/android/androidinst.hxx
@@ -60,7 +60,6 @@ public:
     SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle );
 
     // mainloop pieces
-    virtual void Wakeup();
     virtual bool AnyInput( sal_uInt16 nType );
 
     // incoming android event handlers:
commit 78e217bcd039aa4dc3cf3eb41801d3b307941e4d
Author: Tor Lillqvist <tml at iki.fi>
Date:   Fri Mar 8 20:48:43 2013 +0200

    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

diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 89a8e68..9614d2b 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());
 }
diff --git a/vcl/inc/android/androidinst.hxx b/vcl/inc/android/androidinst.hxx
index 77b6fd3..22800f0 100644
--- a/vcl/inc/android/androidinst.hxx
+++ b/vcl/inc/android/androidinst.hxx
@@ -47,11 +47,6 @@ class AndroidSalInstance : public SvpSalInstance
     // in which soffice_main() runs
     JNIEnv *m_pJNIEnv;
 
-    // The Desktop class
-    jclass m_nDesktopClass;
-
-    jmethodID m_nCallbackDamaged;
-
 public:
     AndroidSalInstance( SalYieldMutex *pMutex );
     virtual ~AndroidSalInstance();


More information about the Libreoffice-commits mailing list