Languages

Menu
Sites
Language
crash issue while call elm_map_overlay_del() of map widget api

Hi, All

I have an UI Application with a map widget, I create some icon overlays and one bubble overlay on the map. 

I am trying to delete these overlays in an button's click callback, the app crashed while call elm_map_overlay_del(), post the crash log here, hope the expert can help me to solve this issue. Thank You !!!

Eina_List *list;
Elm_Map_Overlay *data;

list = elm_map_overlays_get(ad->map);
if(list) {
    EINA_LIST_FREE(list, data) 
    elm_map_overlay_del(data); 

log:

Callstack Information (PID:6308)

Call Stack Count: 23

0: elm_map_overlay_del + 0x1f (0xb74df50f) [/usr/lib/libelementary.so.1] + 0x1d550f

1: _overlays_clear + 0xb9 (0xb4b002b9) [/opt/usr/apps/org.example.gpsdemo/bin/gpsdemo] + 0x42b9

2: _btn_searchtxt_clicked_cb + 0x3c (0xb4afffdc) [/opt/usr/apps/org.example.gpsdemo/bin/gpsdemo] + 0x3fdc

3: (0xb712a906) [/usr/lib/libevas.so.1] + 0x88906

4: (0xb671a979) [/usr/lib/libeo.so.1] + 0xe979

5: eo_event_callback_call + 0xb3 (0xb6717d33) [/usr/lib/libeo.so.1] + 0xbd33

6: evas_object_smart_callback_call + 0x75 (0xb712d1d5) [/usr/lib/libevas.so.1] + 0x8b1d5

7: (0xb73dcd64) [/usr/lib/libelementary.so.1] + 0xd2d64

8: (0xb7010fc9) [/usr/lib/libedje.so.1] + 0x83fc9

9: (0xb7018881) [/usr/lib/libedje.so.1] + 0x8b881

10: (0xb701206c) [/usr/lib/libedje.so.1] + 0x8506c

11: (0xb701255b) [/usr/lib/libedje.so.1] + 0x8555b

12: (0xb701271f) [/usr/lib/libedje.so.1] + 0x8571f

13: (0xb7078782) [/usr/lib/libecore.so.1] + 0x13782

14: (0xb70720d5) [/usr/lib/libecore.so.1] + 0xd0d5

15: (0xb707b239) [/usr/lib/libecore.so.1] + 0x16239

16: ecore_main_loop_begin + 0x57 (0xb707b607) [/usr/lib/libecore.so.1] + 0x16607

17: elm_run + 0x17 (0xb74cdd47) [/usr/lib/libelementary.so.1] + 0x1c3d47

18: appcore_efl_main + 0x4be (0xb76eeb2e) [/usr/lib/libappcore-efl.so.1] + 0x3b2e

19: ui_app_main + 0x140 (0xb586bfb0) [/usr/lib/libcapi-appfw-application.so.0] + 0x4fb0

20: main + 0x2aa (0xb4afe5ca) [/opt/usr/apps/org.example.gpsdemo/bin/gpsdemo] + 0x25ca

21: (0xb77220fa) [/opt/usr/apps/org.example.gpsdemo/bin/gpsdemo] + 0xb77220fa

22: __libc_start_main + 0xde (0xb6c19e4e) [/lib/libc.so.6] + 0x17e4e

End of Call Stack

Responses

11 Replies
Jeongsu Kim

I checked elm_map.c sources and it seems that elm_map_overlays_get returns ELM_MAP_OVERLAY_TYPE_GROUP style overlay that is created by elm_map itself.

How about check overlay type first?

Eina_List *list;
Elm_Map_Overlay *data;

list = elm_map_overlays_get(ad->map);
if(list) {
    EINA_LIST_FREE(list, data) 
    {
        if(elm_map_overlay_type_get(data != ELM_MAP_OVERLAY_TYPE_GROUP)
            elm_map_overlay_del(data); 
    }
}

Or make your own overlay list when you add an overlay and del overlays in the list.

Jeongsu Kim
colin Rao

Thanks! 

But it still crash. Possible it's a bug of map widget.

Jeongsu Kim

I suggested 2 ideas. Did you try it all?

1. check overlay type
2. make your own list

Jean Yang

Hi Colin,

   Can u paste the codes where added the data into the map overlay nodes? Basicly, if the data is added by your code, only u should to destroy them. No anywhere except your code should release these data.

Jean Yang

If all of the data are added in by yourself, you should can covert each data get by EINA_LIST_FREE(list, data) back the original stucturized data and check if the detail info of each data same with where you added them in overlay. Then you can compare if these data are correctly passed back to you by elm_map_overlays_get().

Alex Dem

Hi,
Often the cause of crash is due the data is released(freed) twice. I did not use EINA_LIST FREE but it looks ok. Is it crashed on first iteration? 
Alexey.

colin Rao

Hi,

Thanks all of you!

As Jeongsu Kim's suggestion, by implement an arrary to store the created overlays and delete by for loop. The crash issue was gone.

typedef struct appdata {
    ...
    int                overlays_num;
    Elm_Map_Overlay    *overlays[20];
} appdata_s;

static Elm_Map_Overlay*
add_overlay_on_map(appdata_s *ad, AddressInfo *addr)
{
    Elm_Map_Overlay *ovl;
    Evas_Object *icon;

    // Add an overlay
    ovl = elm_map_overlay_add(ad->map, addr->longitude, addr->latitude);
    ...

    return ovl;
}

// create and store the overlays in a loop
ad->overlays[i] = add_overlay_on_map(ad, temp);

// clear all the created overlays
for (int i = 0; i < ad->overlays_num; i++) {
    elm_map_overlay_del(ad->overlays[i]);
    ad->overlays[i] = NULL;
}
ad->overlays_num = 0;

 

Alex Dem

Hi,
fyi, Maybe to bypass all the nodes of the tree you could try to use EINA_LIST_FOREACH and perform some actions inside.
Alexey.

colin Rao

thanks !!!

I've ever tried the similiar one "EINA_LIST_FOREACH_SAFE", but failed. I think it's same with the "EINA_LIST_FOREACH". But anyway, the issue was fixed. 

Jean Yang

Hi Colin, have u compare the overlay objects retrieve from elm_map_overlays_get() with the the overlay objects you added in?

They must be different!

Do the comparation then you can understand if there are some bugs on the function elm_map_overlays_get(). If there is no bug, then it must be the usage are different with our intuition, that also means the design for this function is not good or at least  its documentation is not good.