Mercurial > dwindows
comparison android/dw.cpp @ 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 |
comparison
equal
deleted
inserted
replaced
2558:ebc6a4ff5f1f | 2559:b5e8a319fde6 |
---|---|
3008 * Returns: | 3008 * Returns: |
3009 * DW_ERROR_NONE (0) on success. | 3009 * DW_ERROR_NONE (0) on success. |
3010 */ | 3010 */ |
3011 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | 3011 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) |
3012 { | 3012 { |
3013 int retval = DW_ERROR_GENERAL; | |
3014 | |
3013 if(handle && flags && titles && count > 0) | 3015 if(handle && flags && titles && count > 0) |
3014 { | 3016 { |
3015 int z; | 3017 int z; |
3016 | 3018 |
3017 for(z=0;z<count;z++) | 3019 for(z=0;z<count;z++) |
3018 { | 3020 { |
3019 JNIEnv *env; | 3021 JNIEnv *env; |
3020 | 3022 |
3021 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 3023 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
3022 { | 3024 { |
3025 retval = DW_ERROR_NONE; | |
3026 | |
3023 // Generate a string | 3027 // Generate a string |
3024 jstring jstr = env->NewStringUTF(titles[z]); | 3028 jstring jstr = env->NewStringUTF(titles[z]); |
3025 // First get the class that contains the method you need to call | 3029 // First get the class that contains the method you need to call |
3026 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 3030 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
3027 // Get the method that you want to call | 3031 // Get the method that you want to call |
3028 jmethodID containerNew = env->GetMethodID(clazz, "containerAddColumn", | 3032 jmethodID containerNew = env->GetMethodID(clazz, "containerAddColumn", |
3029 "(Landroid/widget/ListView;Ljava/lang/String;I)V"); | 3033 "(Landroid/widget/ListView;Ljava/lang/String;I)V"); |
3030 // Call the method on the object | 3034 // Call the method on the object |
3031 env->CallVoidMethod(_dw_obj, containerNew, handle, jstr, (int)flags[z]); | 3035 env->CallVoidMethod(_dw_obj, containerNew, handle, jstr, (int)flags[z]); |
3032 if(!_dw_jni_check_exception(env)) | 3036 if(_dw_jni_check_exception(env)) |
3033 return DW_ERROR_NONE; | 3037 retval = DW_ERROR_GENERAL; |
3034 } | 3038 } |
3035 } | 3039 } |
3036 } | 3040 } |
3037 return DW_ERROR_GENERAL; | 3041 return retval; |
3038 } | 3042 } |
3039 | 3043 |
3040 /* | 3044 /* |
3041 * Configures the main filesystem column title for localization. | 3045 * Configures the main filesystem column title for localization. |
3042 * Parameters: | 3046 * Parameters: |
3601 // Get the method that you want to call | 3605 // Get the method that you want to call |
3602 jmethodID iconNew = env->GetMethodID(clazz, "iconNew", | 3606 jmethodID iconNew = env->GetMethodID(clazz, "iconNew", |
3603 "(Ljava/lang/String;[BII)Landroid/graphics/drawable/Drawable;"); | 3607 "(Ljava/lang/String;[BII)Landroid/graphics/drawable/Drawable;"); |
3604 // Call the method on the object | 3608 // Call the method on the object |
3605 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, iconNew, | 3609 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, iconNew, |
3606 file, bytearray, len, resid), _DW_REFERENCE_WEAK); | 3610 file, bytearray, len, resid), _DW_REFERENCE_STRONG); |
3607 // Clean up after the array now that we are finished | 3611 // Clean up after the array now that we are finished |
3608 //if(bytearray) | 3612 //if(bytearray) |
3609 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); | 3613 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); |
3610 return result; | 3614 return result; |
3611 } | 3615 } |