This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit f28acf6b1e386fe473b5225b2d55bbc64d58e411
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Oct 30 00:00:16 2026 -0600
elementary: Image_Zoomable loads a file or icon given at construction
A file or icon set inside efl_add() was never loaded: file_set only
keeps the name, and the Efl.File mixin's finalize load asked this class
for its loaded state, which it did not keep. Worse, for an icon that
load then unloaded what the icon had set up.
Keep a private loaded flag, set by a successful load, an icon and a
remote download, and cleared by unload, a new file and a new key.
efl_file_load does nothing once it is set, so the mixin's finalize load
leaves an icon alone, and Efl.File.loaded reports it. A finalize
override loads a file that was set while constructing, as Efl.Ui.Image
does.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_image_zoomable.c | 40 ++++++++++++++++++++--
src/lib/elementary/efl_ui_image_zoomable.eo | 3 ++
src/lib/elementary/efl_ui_image_zoomable_private.h | 1 +
src/tests/elementary/efl_ui_test_image_zoomable.c | 22 ++++++++++++
4 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/src/lib/elementary/efl_ui_image_zoomable.c b/src/lib/elementary/efl_ui_image_zoomable.c
index f7b83caf8d..c910fa48cd 100644
--- a/src/lib/elementary/efl_ui_image_zoomable.c
+++ b/src/lib/elementary/efl_ui_image_zoomable.c
@@ -1952,6 +1952,17 @@ _efl_ui_image_zoomable_efl_object_constructor(Eo *obj, Efl_Ui_Image_Zoomable_Dat
return obj;
}
+EOLIAN static Eo *
+_efl_ui_image_zoomable_efl_object_finalize(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd)
+{
+ obj = efl_finalize(efl_super(obj, MY_CLASS));
+ if (!obj) return NULL;
+ /* A file set while constructing is loaded here, as for Efl.Ui.Image:
+ * file_set only keeps the name, and the mixin does not know of it. */
+ if (sd->file && !sd->loaded) efl_file_load(obj);
+ return obj;
+}
+
EOLIAN static Eina_Size2D
_efl_ui_image_zoomable_efl_gfx_image_image_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *pd)
{
@@ -2214,6 +2225,7 @@ _efl_ui_image_zoomable_remote_copier_done(void *data, const Efl_Event *event EIN
efl_file_mmap_set(obj, f);
eina_file_close(f);
ret = _internal_file_set(obj, sd, &ret);
+ sd->loaded = !ret;
if (ret)
{
@@ -2350,6 +2362,7 @@ _efl_ui_image_zoomable_efl_file_unload(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd)
{
ELM_SAFE_FREE(sd->edje, evas_object_del);
eina_stringshare_replace(&sd->stdicon, NULL);
+ sd->loaded = EINA_FALSE;
_grid_clear_all(obj);
_efl_ui_image_zoomable_zoom_reset(obj, sd);
@@ -2374,10 +2387,17 @@ _efl_ui_image_zoomable_efl_file_load(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd)
Evas_Load_Error ret;
Eina_Error err;
- if (efl_file_loaded_get(obj)) return 0;
+ /* This class does not keep the loaded state of Efl.File: an icon, or
+ * what an earlier load did, is not to be undone by the load that
+ * Efl.File's finalize asks for. */
+ if (sd->loaded) return 0;
err = _efl_ui_image_zoomable_file_set_internal(obj, sd, &ret);
- if ((!ret) && (!err)) return 0;
+ if ((!ret) && (!err))
+ {
+ sd->loaded = EINA_TRUE;
+ return 0;
+ }
eina_error_set(
ret == EVAS_LOAD_ERROR_DOES_NOT_EXIST ? PHOTO_FILE_LOAD_ERROR_DOES_NOT_EXIST :
@@ -2401,9 +2421,24 @@ _efl_ui_image_zoomable_efl_file_file_set(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd
if (mmap && !eina_streq(eina_file_filename_get(mmap), file))
efl_file_mmap_set(obj, NULL);
eina_stringshare_replace(&sd->file, file);
+ sd->loaded = EINA_FALSE;
return 0;
}
+EOLIAN static void
+_efl_ui_image_zoomable_efl_file_key_set(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, const char *key)
+{
+ efl_file_key_set(efl_super(obj, MY_CLASS), key);
+ /* Another key is another thing to load from the same file. */
+ sd->loaded = EINA_FALSE;
+}
+
+EOLIAN static Eina_Bool
+_efl_ui_image_zoomable_efl_file_loaded_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd)
+{
+ return sd->loaded;
+}
+
EOLIAN static const char *
_efl_ui_image_zoomable_efl_file_file_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd)
{
@@ -2941,6 +2976,7 @@ _internal_efl_ui_image_zoomable_icon_set(Evas_Object *obj, const char *name, Ein
if (ret)
{
eina_stringshare_replace(&sd->stdicon, name);
+ sd->loaded = EINA_TRUE;
_sizing_eval(obj);
return EINA_TRUE;
}
diff --git a/src/lib/elementary/efl_ui_image_zoomable.eo b/src/lib/elementary/efl_ui_image_zoomable.eo
index 20424a568d..3a8f9b54c6 100644
--- a/src/lib/elementary/efl_ui_image_zoomable.eo
+++ b/src/lib/elementary/efl_ui_image_zoomable.eo
@@ -41,6 +41,7 @@ class Efl.Ui.Image_Zoomable extends Efl.Ui.Image implements Efl.Ui.Zoom
implements {
class.constructor;
Efl.Object.constructor;
+ Efl.Object.finalize;
Efl.Gfx.Entity.position { set; }
Efl.Gfx.Entity.size { set; }
Efl.Gfx.View.view_size { get; }
@@ -66,6 +67,8 @@ class Efl.Ui.Image_Zoomable extends Efl.Ui.Image implements Efl.Ui.Zoom
Efl.File.load;
Efl.File.unload;
Efl.File.file { get; set; }
+ Efl.File.key { set; }
+ Efl.File.loaded { get; }
Efl.Gfx.Image_Orientable.image_orientation { get; set; }
Efl.Layout.Group.group_size_min { get; }
Efl.Layout.Group.group_size_max { get; }
diff --git a/src/lib/elementary/efl_ui_image_zoomable_private.h b/src/lib/elementary/efl_ui_image_zoomable_private.h
index 296c98d481..f2374f5327 100644
--- a/src/lib/elementary/efl_ui_image_zoomable_private.h
+++ b/src/lib/elementary/efl_ui_image_zoomable_private.h
@@ -138,6 +138,7 @@ struct _Efl_Ui_Image_Zoomable_Data
Eina_Bool do_region : 1;
Eina_Bool zoom_g_layer : 1;
Eina_Bool resized : 1;
+ Eina_Bool loaded : 1; /* what is set, file or icon, has been loaded */
Eina_Bool on_hold : 1;
Eina_Bool paused : 1;
Eina_Bool orientation_changed : 1;
diff --git a/src/tests/elementary/efl_ui_test_image_zoomable.c b/src/tests/elementary/efl_ui_test_image_zoomable.c
index c68c881ab9..5cff2f2ba1 100644
--- a/src/tests/elementary/efl_ui_test_image_zoomable.c
+++ b/src/tests/elementary/efl_ui_test_image_zoomable.c
@@ -100,9 +100,31 @@ EFL_START_TEST(efl_ui_test_image_zoomable_file_after_icon)
}
EFL_END_TEST
+EFL_START_TEST(efl_ui_test_image_zoomable_set_while_constructing)
+{
+ Evas_Object *win, *img_zoomable;
+ Eina_Size2D size;
+
+ win = win_add(NULL, "photocam", EFL_UI_WIN_TYPE_BASIC);
+
+ img_zoomable = efl_add(EFL_UI_IMAGE_ZOOMABLE_CLASS, win,
+ efl_file_set(efl_added, ELM_IMAGE_DATA_DIR"/images/logo.png"));
+ ck_assert(efl_file_loaded_get(img_zoomable));
+ size = efl_gfx_view_size_get(img_zoomable);
+ ck_assert_int_gt(size.w, 0);
+ ck_assert_int_gt(size.h, 0);
+
+ img_zoomable = efl_add(EFL_UI_IMAGE_ZOOMABLE_CLASS, win,
+ efl_ui_image_icon_set(efl_added, "folder"));
+ ck_assert(efl_file_loaded_get(img_zoomable));
+ ck_assert_str_eq(efl_ui_image_icon_get(img_zoomable), "folder");
+}
+EFL_END_TEST
+
void efl_ui_test_image_zoomable(TCase *tc)
{
tcase_add_test(tc, efl_ui_test_image_zoomable_icon);
tcase_add_test(tc, efl_ui_test_image_zoomable_replaced_calc_job);
tcase_add_test(tc, efl_ui_test_image_zoomable_file_after_icon);
+ tcase_add_test(tc, efl_ui_test_image_zoomable_set_while_constructing);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.