summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-03-17 11:01:56 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-03-17 13:55:01 +0900
commitd1796f9aa678bcb91eeca75096a16ccfb759ad5f (patch)
treea7d64b967e266b3f1c1587ea1ba896aa983d1277
parent31fb6e3258da7c9a9e8b7fb5d497ad9ad5543b7b (diff)
Elm.Image: Improve error message after load failure
"Things are going bad for <path> (<internal pointer>)" was pretty useless, and confusing to some people. Also, simplify code wrt. returning a bool...
-rw-r--r--src/lib/elm_image.c83
1 files changed, 40 insertions, 43 deletions
diff --git a/src/lib/elm_image.c b/src/lib/elm_image.c
index 91e373a6d..538c5b9e4 100644
--- a/src/lib/elm_image.c
+++ b/src/lib/elm_image.c
@@ -34,7 +34,7 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
34}; 34};
35 35
36static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params); 36static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
37static void _elm_image_smart_internal_file_set(Eo *obj, Elm_Image_Data *sd, const char *file, const Eina_File *f, const char *key, Eina_Bool *ret); 37static Eina_Bool _elm_image_smart_internal_file_set(Eo *obj, Elm_Image_Data *sd, const char *file, const Eina_File *f, const char *key);
38 38
39static const Elm_Action key_actions[] = { 39static const Elm_Action key_actions[] = {
40 {"activate", _key_action_activate}, 40 {"activate", _key_action_activate},
@@ -375,23 +375,12 @@ _elm_image_async_open_done(void *data, Ecore_Thread *thread EINA_UNUSED)
375 else 375 else
376 file = f ? eina_file_filename_get(f) : NULL; 376 file = f ? eina_file_filename_get(f) : NULL;
377 377
378 if (sd->edje) 378 if (ok)
379 {
380 if (ok) ok = edje_object_mmap_set(sd->img, f, key);
381 if (!ok)
382 {
383 ERR("failed to open edje file '%s', group '%s': %s", file, key,
384 edje_load_error_str(edje_object_load_error_get(sd->img)));
385 }
386 }
387 else
388 { 379 {
389 if (ok) _elm_image_smart_internal_file_set(obj, sd, file, f, key, &ok); 380 if (sd->edje)
390 if (!ok) 381 ok = edje_object_mmap_set(sd->img, f, key);
391 { 382 else
392 ERR("failed to open image file '%s', key '%s': %s", file, key, 383 ok = _elm_image_smart_internal_file_set(obj, sd, file, f, key);
393 evas_load_error_str(evas_object_image_load_error_get(sd->img)));
394 }
395 } 384 }
396 385
397 if (ok) 386 if (ok)
@@ -899,6 +888,8 @@ _elm_image_file_set_do(Evas_Object *obj)
899EOLIAN static Eina_Bool 888EOLIAN static Eina_Bool
900_elm_image_memfile_set(Eo *obj, Elm_Image_Data *sd, const void *img, size_t size, const char *format, const char *key) 889_elm_image_memfile_set(Eo *obj, Elm_Image_Data *sd, const void *img, size_t size, const char *format, const char *key)
901{ 890{
891 Evas_Load_Error err;
892
902 _elm_image_file_set_do(obj); 893 _elm_image_file_set_do(obj);
903 894
904 evas_object_image_memfile_set 895 evas_object_image_memfile_set
@@ -907,11 +898,12 @@ _elm_image_memfile_set(Eo *obj, Elm_Image_Data *sd, const void *img, size_t size
907 sd->preload_status = ELM_IMAGE_PRELOADING; 898 sd->preload_status = ELM_IMAGE_PRELOADING;
908 evas_object_image_preload(sd->img, EINA_FALSE); 899 evas_object_image_preload(sd->img, EINA_FALSE);
909 900
910 if (evas_object_image_load_error_get(sd->img) != EVAS_LOAD_ERROR_NONE) 901 err = evas_object_image_load_error_get(sd->img);
902 if (err != EVAS_LOAD_ERROR_NONE)
911 { 903 {
912 if (img) 904 if (img)
913 ERR("Things are going bad for some random " FMT_SIZE_T 905 ERR("Failed to load image from memory block (" FMT_SIZE_T
914 " byte chunk of memory (%p)", size, sd->img); 906 " bytes): %s (%p)", size, evas_load_error_str(err), sd->img);
915 else 907 else
916 ERR("NULL image data passed (%p)", sd->img); 908 ERR("NULL image data passed (%p)", sd->img);
917 return EINA_FALSE; 909 return EINA_FALSE;
@@ -998,16 +990,14 @@ _elm_image_efl_file_mmap_set(Eo *obj, Elm_Image_Data *pd EINA_UNUSED,
998 return ret; 990 return ret;
999} 991}
1000 992
1001static void 993static Eina_Bool
1002_elm_image_smart_internal_file_set(Eo *obj, Elm_Image_Data *sd, 994_elm_image_smart_internal_file_set(Eo *obj, Elm_Image_Data *sd,
1003 const char *file, const Eina_File *f, const char *key, Eina_Bool *ret) 995 const char *file, const Eina_File *f, const char *key)
1004{ 996{
997 Evas_Load_Error err;
998
1005 if (eina_str_has_extension(file, ".edj")) 999 if (eina_str_has_extension(file, ".edj"))
1006 { 1000 return _elm_image_edje_file_set(obj, file, f, key);
1007 Eina_Bool int_ret = _elm_image_edje_file_set(obj, file, f, key);
1008 if (ret) *ret = int_ret;
1009 return;
1010 }
1011 1001
1012 _elm_image_file_set_do(obj); 1002 _elm_image_file_set_do(obj);
1013 1003
@@ -1016,14 +1006,25 @@ _elm_image_smart_internal_file_set(Eo *obj, Elm_Image_Data *sd,
1016 else 1006 else
1017 evas_object_image_file_set(sd->img, file, key); 1007 evas_object_image_file_set(sd->img, file, key);
1018 1008
1019 if (evas_object_image_load_error_get(sd->img) != EVAS_LOAD_ERROR_NONE) 1009 err = evas_object_image_load_error_get(sd->img);
1010 if (err != EVAS_LOAD_ERROR_NONE)
1020 { 1011 {
1021 if (file) 1012 if (file || f)
1022 ERR("Things are going bad for '%s' (%p)", file, sd->img); 1013 {
1014 if (key)
1015 ERR("Failed to load image '%s' '%s': %s. (%p)",
1016 file ? file : eina_file_filename_get(f), key,
1017 evas_load_error_str(err), obj);
1018 else
1019 ERR("Failed to load image '%s': %s. (%p)",
1020 file ? file : eina_file_filename_get(f),
1021 evas_load_error_str(err), obj);
1022 }
1023 else 1023 else
1024 ERR("NULL image file passed (%p)", sd->img); 1024 {
1025 if (ret) *ret = EINA_FALSE; 1025 ERR("NULL image file passed! (%p)", obj);
1026 return; 1026 }
1027 return EINA_FALSE;
1027 } 1028 }
1028 1029
1029 if (sd->preload_status != ELM_IMAGE_PRELOAD_DISABLED) 1030 if (sd->preload_status != ELM_IMAGE_PRELOAD_DISABLED)
@@ -1035,11 +1036,11 @@ _elm_image_smart_internal_file_set(Eo *obj, Elm_Image_Data *sd,
1035 1036
1036 _elm_image_internal_sizing_eval(obj, sd); 1037 _elm_image_internal_sizing_eval(obj, sd);
1037 1038
1038 if (ret) *ret = EINA_TRUE; 1039 return EINA_TRUE;
1039} 1040}
1040 1041
1041static void 1042static void
1042_elm_image_smart_download_done(void *data, Elm_Url *url EINA_UNUSED, Eina_Binbuf *download) 1043_elm_image_smart_download_done(void *data, Elm_Url *url, Eina_Binbuf *download)
1043{ 1044{
1044 Eo *obj = data; 1045 Eo *obj = data;
1045 Elm_Image_Data *sd = eo_data_scope_get(obj, MY_CLASS); 1046 Elm_Image_Data *sd = eo_data_scope_get(obj, MY_CLASS);
@@ -1053,7 +1054,7 @@ _elm_image_smart_download_done(void *data, Elm_Url *url EINA_UNUSED, Eina_Binbuf
1053 f = eina_file_virtualize(_elm_url_get(url), 1054 f = eina_file_virtualize(_elm_url_get(url),
1054 sd->remote_data, length, 1055 sd->remote_data, length,
1055 EINA_FALSE); 1056 EINA_FALSE);
1056 _elm_image_smart_internal_file_set(obj, sd, _elm_url_get(url), f, sd->key, &ret); 1057 ret = _elm_image_smart_internal_file_set(obj, sd, _elm_url_get(url), f, sd->key);
1057 eina_file_close(f); 1058 eina_file_close(f);
1058 1059
1059 sd->remote = NULL; 1060 sd->remote = NULL;
@@ -1144,7 +1145,7 @@ _elm_image_efl_file_file_set(Eo *obj, Elm_Image_Data *sd, const char *file, cons
1144 } 1145 }
1145 1146
1146 if (!sd->async_enable) 1147 if (!sd->async_enable)
1147 _elm_image_smart_internal_file_set(obj, sd, file, NULL, key, &ret); 1148 ret = _elm_image_smart_internal_file_set(obj, sd, file, NULL, key);
1148 else 1149 else
1149 ret = _elm_image_async_file_set(obj, sd, file, NULL, key); 1150 ret = _elm_image_async_file_set(obj, sd, file, NULL, key);
1150 1151
@@ -1201,11 +1202,7 @@ _elm_image_mmap_set(Eo *obj, Elm_Image_Data *sd, const Eina_File *f, const char
1201 sd->remote = NULL; 1202 sd->remote = NULL;
1202 1203
1203 if (!sd->async_enable) 1204 if (!sd->async_enable)
1204 { 1205 ret = _elm_image_smart_internal_file_set(obj, sd, eina_file_filename_get(f), f, key);
1205 _elm_image_smart_internal_file_set(obj, sd,
1206 eina_file_filename_get(f), f,
1207 key, &ret);
1208 }
1209 else 1206 else
1210 ret = _elm_image_async_file_set(obj, sd, eina_file_filename_get(f), f, key); 1207 ret = _elm_image_async_file_set(obj, sd, eina_file_filename_get(f), f, key);
1211 1208
@@ -1387,7 +1384,7 @@ _elm_image_orient_set(Eo *obj, Elm_Image_Data *sd, Elm_Image_Orient orient)
1387 if (sd->edje) return; 1384 if (sd->edje) return;
1388 if (sd->orient == orient) return; 1385 if (sd->orient == orient) return;
1389 1386
1390 evas_object_image_orient_set(sd->img, orient); 1387 evas_object_image_orient_set(sd->img, (Evas_Image_Orient) orient);
1391 sd->orient = orient; 1388 sd->orient = orient;
1392 _elm_image_internal_sizing_eval(obj, sd); 1389 _elm_image_internal_sizing_eval(obj, sd);
1393} 1390}