Page MenuHomePhabricator

Behaviour changed - elm_radio_value_set is calling evas_object_smart_callback function
Closed, ResolvedPublic

Description

Since 89102ecbd3bb99c996d7b34fbbb55900686200bc when elm_radio_value_set is called, an evas_object_smart_callback function associated to the radio button is also called. This wasn't the case in previous versions.
A small example program:

#include <Elementary.h>
// gcc -o radio radio.c $(pkg-config --cflags elementary) $(pkg-config --libs elementary)

static void radio_fun(void *data, Evas_Object *obj, void *event_info){

   fprintf(stdout, "Yis radio_fun\n");
}

static void slider_fun(void *data, Evas_Object *obj, void *event_info){

   fprintf(stdout, "Yis slider_fun\n");
}

static void on_done(void *data, Evas_Object *obj, void *event_info)
{
   fprintf(stdout, "Yis OK\n");
   elm_exit();
}

EAPI_MAIN int elm_main(int argc, char **argv)
{
   static Evas_Object *win, *winbox, *slid_nn, *radio_0, *radio_1;

   // WIN
   win = elm_win_add(NULL, "Normal", ELM_WIN_BASIC);
   //win = elm_win_util_standard_add("maskotti", "Maskotti");
   elm_win_title_set(win, "Normal");
   evas_object_smart_callback_add(win, "delete,request", on_done, NULL);

   // WINBOX
   winbox = elm_box_add(win);
   elm_box_horizontal_set(winbox, EINA_FALSE);
   evas_object_size_hint_align_set(winbox, -0.5, -0.5);
   elm_win_resize_object_add(win, winbox);
   evas_object_show(winbox);

   // SLIDER
   slid_nn = elm_slider_add(win);
   evas_object_smart_callback_add(slid_nn, "delay,changed", slider_fun, NULL);
   elm_slider_horizontal_set(slid_nn, EINA_TRUE);
   elm_box_pack_end(winbox, slid_nn);
   evas_object_show(slid_nn);

   // RADIO BUTTON
   radio_0 = elm_radio_add(win);     
   elm_radio_state_value_set(radio_0, 0);
   elm_object_part_text_set(radio_0, NULL, "Equal");
   evas_object_smart_callback_add(radio_0, "changed", radio_fun, NULL);
   elm_box_pack_end(winbox, radio_0);
   evas_object_show(radio_0);
                                                                                                 
   radio_1 = elm_radio_add(win);                                                      
   elm_radio_state_value_set(radio_1, 1);
   elm_radio_group_add(radio_1, radio_0);
   elm_object_part_text_set(radio_1, NULL, "Spiky");
   evas_object_smart_callback_add(radio_1, "changed", radio_fun, NULL);    
   elm_box_pack_end(winbox, radio_1);
   evas_object_show(radio_1);

   //this calls radio_fun
   elm_radio_value_set(radio_0, 1);

   //this does not call slider_fun
   elm_slider_value_set(slid_nn, 0.5);

   evas_object_show(win);
   elm_run();
   elm_shutdown();

   return 0;
}
ELM_MAIN()

When run for example with EFL 42b293ae1f89aa3737fe7a4d81ebc3596fd2c631 when this program starts, it doesn't print anything. The functions radio_fun and slider_fun are not called at

//this calls radio_fun
elm_radio_value_set(radio_0, 1);

//this does not call slider_fun
elm_slider_value_set(slid_nn, 0.5);

But with current EFL from git, when the program starts it prints

Yis radio_fun
Yis radio_fun

Also strange that radio_fun is obviously called two times.
When you actually click the radio button radio_fun is also called twice.