changeset 2559:b5e8a319fde6

Android: Fix logic error in dw_container_setup() causing return from the loop that creates the container columns. Also the handles to icons should use strong references not weak.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 18 May 2021 07:55:59 +0000
parents ebc6a4ff5f1f
children 3da35cd91ca7
files android/dw.cpp
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/android/dw.cpp	Tue May 18 01:04:52 2021 +0000
+++ b/android/dw.cpp	Tue May 18 07:55:59 2021 +0000
@@ -3010,6 +3010,8 @@
  */
 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
 {
+    int retval = DW_ERROR_GENERAL;
+
     if(handle && flags && titles && count > 0)
     {
         int z;
@@ -3020,6 +3022,8 @@
 
             if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
             {
+                retval = DW_ERROR_NONE;
+
                 // Generate a string
                 jstring jstr = env->NewStringUTF(titles[z]);
                 // First get the class that contains the method you need to call
@@ -3029,12 +3033,12 @@
                                                           "(Landroid/widget/ListView;Ljava/lang/String;I)V");
                 // Call the method on the object
                 env->CallVoidMethod(_dw_obj, containerNew, handle, jstr, (int)flags[z]);
-                if(!_dw_jni_check_exception(env))
-                    return DW_ERROR_NONE;
+                if(_dw_jni_check_exception(env))
+                    retval = DW_ERROR_GENERAL;
             }
         }
     }
-    return DW_ERROR_GENERAL;
+    return retval;
 }
 
 /*
@@ -3603,7 +3607,7 @@
                                              "(Ljava/lang/String;[BII)Landroid/graphics/drawable/Drawable;");
         // Call the method on the object
         jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, iconNew,
-                                              file, bytearray, len, resid), _DW_REFERENCE_WEAK);
+                                              file, bytearray, len, resid), _DW_REFERENCE_STRONG);
         // Clean up after the array now that we are finished
         //if(bytearray)
         //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0);