summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2013-11-18 13:34:07 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2013-11-24 08:54:57 +0200
commit65f37f9ce05676bcbc475153c6e1fde6dab32994 (patch)
tree545b4d158919f8bb6927a74ac3e8308bcc3c524b /src
parent2b5d1c7d3d5b74ce3db4ec6aa723391a0f098ac1 (diff)
DnD: safe inlist elements removal
Diffstat (limited to 'src')
-rw-r--r--src/lib/elm_cnp.c72
1 files changed, 42 insertions, 30 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index b9543ffea..5baeac4d9 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -809,15 +809,16 @@ _x11_notify_handler_text(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify
809 if (dropable) 809 if (dropable)
810 { 810 {
811 Dropable_Cbs *cbs; 811 Dropable_Cbs *cbs;
812 Eina_Inlist *itr;
812 ddata.x = savedtypes.x; 813 ddata.x = savedtypes.x;
813 ddata.y = savedtypes.y; 814 ddata.y = savedtypes.y;
814 ddata.format = ELM_SEL_FORMAT_TEXT; 815 ddata.format = ELM_SEL_FORMAT_TEXT;
815 ddata.data = data->data; 816 ddata.data = data->data;
816 ddata.len = data->length; 817 ddata.len = data->length;
817 ddata.action = sel->action; 818 ddata.action = sel->action;
818 EINA_INLIST_FOREACH(dropable->cbs_list, cbs) 819 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
819 if (cbs->dropcb) 820 if (cbs->dropcb)
820 cbs->dropcb(cbs->dropdata, dropable->obj, &ddata); 821 cbs->dropcb(cbs->dropdata, dropable->obj, &ddata);
821 goto end; 822 goto end;
822 } 823 }
823 } 824 }
@@ -965,6 +966,7 @@ _x11_vcard_receive(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notif
965 if (sel == (_x11_selections + ELM_SEL_TYPE_XDND)) 966 if (sel == (_x11_selections + ELM_SEL_TYPE_XDND))
966 { 967 {
967 Dropable_Cbs *cbs; 968 Dropable_Cbs *cbs;
969 Eina_Inlist *itr;
968 Elm_Selection_Data ddata; 970 Elm_Selection_Data ddata;
969 971
970 cnp_debug("drag & drop\n"); 972 cnp_debug("drag & drop\n");
@@ -986,9 +988,9 @@ _x11_vcard_receive(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notif
986 ddata.data = data->data; 988 ddata.data = data->data;
987 ddata.len = data->length; 989 ddata.len = data->length;
988 ddata.action = sel->action; 990 ddata.action = sel->action;
989 EINA_INLIST_FOREACH(dropable->cbs_list, cbs) 991 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
990 if (cbs->dropcb) 992 if (cbs->dropcb)
991 cbs->dropcb(cbs->dropdata, dropable->obj, &ddata); 993 cbs->dropcb(cbs->dropdata, dropable->obj, &ddata);
992 ecore_x_dnd_send_finished(); 994 ecore_x_dnd_send_finished();
993 } 995 }
994 else if (sel->datacb) 996 else if (sel->datacb)
@@ -1297,6 +1299,7 @@ _x11_dnd_dropable_handle(Dropable *dropable, Evas_Coord x, Evas_Coord y, Eina_Bo
1297{ 1299{
1298 Dropable *dropable_last = NULL; 1300 Dropable *dropable_last = NULL;
1299 Dropable_Cbs *cbs; 1301 Dropable_Cbs *cbs;
1302 Eina_Inlist *itr;
1300 1303
1301 if (dropable->last.in) 1304 if (dropable->last.in)
1302 dropable_last = _x11_dropable_geom_find 1305 dropable_last = _x11_dropable_geom_find
@@ -1305,39 +1308,39 @@ _x11_dnd_dropable_handle(Dropable *dropable, Evas_Coord x, Evas_Coord y, Eina_Bo
1305 if ((have_obj) && (dropable_last == dropable)) // same 1308 if ((have_obj) && (dropable_last == dropable)) // same
1306 { 1309 {
1307 cnp_debug("same obj dropable %p\n", dropable); 1310 cnp_debug("same obj dropable %p\n", dropable);
1308 EINA_INLIST_FOREACH(dropable->cbs_list, cbs) 1311 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
1309 if (cbs->poscb) 1312 if (cbs->poscb)
1310 cbs->poscb(cbs->posdata, dropable->obj, x, y, action); 1313 cbs->poscb(cbs->posdata, dropable->obj, x, y, action);
1311 } 1314 }
1312 else if ((have_obj) && (!dropable_last)) // enter new obj 1315 else if ((have_obj) && (!dropable_last)) // enter new obj
1313 { 1316 {
1314 cnp_debug("enter %p\n", dropable->obj); 1317 cnp_debug("enter %p\n", dropable->obj);
1315 EINA_INLIST_FOREACH(dropable->cbs_list, cbs) 1318 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
1316 if (cbs->entercb) 1319 if (cbs->entercb)
1317 cbs->entercb(cbs->enterdata, dropable->obj); 1320 cbs->entercb(cbs->enterdata, dropable->obj);
1318 EINA_INLIST_FOREACH(dropable->cbs_list, cbs) 1321 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
1319 if (cbs->poscb) 1322 if (cbs->poscb)
1320 cbs->poscb(cbs->posdata, dropable->obj, x, y, action); 1323 cbs->poscb(cbs->posdata, dropable->obj, x, y, action);
1321 } 1324 }
1322 else if ((!have_obj) && (dropable_last)) // leave last obj 1325 else if ((!have_obj) && (dropable_last)) // leave last obj
1323 { 1326 {
1324 cnp_debug("leave %p\n", dropable_last->obj); 1327 cnp_debug("leave %p\n", dropable_last->obj);
1325 EINA_INLIST_FOREACH(dropable->cbs_list, cbs) 1328 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
1326 if (cbs->leavecb) 1329 if (cbs->leavecb)
1327 cbs->leavecb(cbs->leavedata, dropable->obj); 1330 cbs->leavecb(cbs->leavedata, dropable->obj);
1328 } 1331 }
1329 else if (have_obj) // leave last obj and enter new one 1332 else if (have_obj) // leave last obj and enter new one
1330 { 1333 {
1331 cnp_debug("enter %p\n", dropable->obj); 1334 cnp_debug("enter %p\n", dropable->obj);
1332 EINA_INLIST_FOREACH(dropable->cbs_list, cbs) 1335 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
1333 if (cbs->entercb) 1336 if (cbs->entercb)
1334 cbs->entercb(cbs->enterdata, dropable->obj); 1337 cbs->entercb(cbs->enterdata, dropable->obj);
1335 if (dropable_last) 1338 if (dropable_last)
1336 { 1339 {
1337 dropable = dropable_last; 1340 dropable = dropable_last;
1338 EINA_INLIST_FOREACH(dropable->cbs_list, cbs) 1341 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
1339 if (cbs->leavecb) 1342 if (cbs->leavecb)
1340 cbs->leavecb(cbs->leavedata, dropable->obj); 1343 cbs->leavecb(cbs->leavedata, dropable->obj);
1341 cnp_debug("leave %p\n", dropable->obj); 1344 cnp_debug("leave %p\n", dropable->obj);
1342 } 1345 }
1343 } 1346 }
@@ -1522,11 +1525,12 @@ found:
1522 ddata.action = act; 1525 ddata.action = act;
1523 1526
1524 Dropable_Cbs *cbs; 1527 Dropable_Cbs *cbs;
1525 EINA_INLIST_FOREACH(dropable->cbs_list, cbs) 1528 Eina_Inlist *itr;
1529 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
1526 { 1530 {
1527 /* If it's markup that also supports images */ 1531 /* If it's markup that also supports images */
1528 if ((cbs->types & ELM_SEL_FORMAT_MARKUP) && 1532 if ((cbs->types & ELM_SEL_FORMAT_MARKUP) &&
1529 (cbs->types & ELM_SEL_FORMAT_IMAGE)) 1533 (cbs->types & ELM_SEL_FORMAT_IMAGE))
1530 { 1534 {
1531 int len; 1535 int len;
1532 ddata.format = ELM_SEL_FORMAT_MARKUP; 1536 ddata.format = ELM_SEL_FORMAT_MARKUP;
@@ -1536,14 +1540,16 @@ found:
1536 snprintf(entrytag, len + 1, tagstring, savedtypes.imgfile); 1540 snprintf(entrytag, len + 1, tagstring, savedtypes.imgfile);
1537 ddata.data = entrytag; 1541 ddata.data = entrytag;
1538 cnp_debug("Insert %s\n", (char *)ddata.data); 1542 cnp_debug("Insert %s\n", (char *)ddata.data);
1539 if (cbs->dropcb) cbs->dropcb(cbs->dropdata, dropable->obj, &ddata); 1543 if (cbs->dropcb)
1544 cbs->dropcb(cbs->dropdata, dropable->obj, &ddata);
1540 } 1545 }
1541 else if (cbs->types & ELM_SEL_FORMAT_IMAGE) 1546 else if (cbs->types & ELM_SEL_FORMAT_IMAGE)
1542 { 1547 {
1543 cnp_debug("Doing image insert (%s)\n", savedtypes.imgfile); 1548 cnp_debug("Doing image insert (%s)\n", savedtypes.imgfile);
1544 ddata.format = ELM_SEL_FORMAT_IMAGE; 1549 ddata.format = ELM_SEL_FORMAT_IMAGE;
1545 ddata.data = (char *)savedtypes.imgfile; 1550 ddata.data = (char *)savedtypes.imgfile;
1546 if (cbs->dropcb) cbs->dropcb(cbs->dropdata, dropable->obj, &ddata); 1551 if (cbs->dropcb)
1552 cbs->dropcb(cbs->dropdata, dropable->obj, &ddata);
1547 } 1553 }
1548 else 1554 else
1549 { 1555 {
@@ -1736,7 +1742,7 @@ _x11_elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection, Elm_Sel_For
1736 sel->active = EINA_TRUE; 1742 sel->active = EINA_TRUE;
1737 sel->widget = obj; 1743 sel->widget = obj;
1738 sel->xwin = xwin; 1744 sel->xwin = xwin;
1739 sel->set(xwin, &selection, sizeof(Elm_Sel_Type)); 1745 if (sel->set) sel->set(xwin, &selection, sizeof(Elm_Sel_Type));
1740 sel->format = format; 1746 sel->format = format;
1741 sel->loss_cb = NULL; 1747 sel->loss_cb = NULL;
1742 sel->loss_data = NULL; 1748 sel->loss_data = NULL;
@@ -1854,8 +1860,6 @@ _x11_elm_drop_target_add(Evas_Object *obj, Elm_Sel_Format format,
1854 1860
1855 _x11_elm_cnp_init(); 1861 _x11_elm_cnp_init();
1856 1862
1857 /* TODO: check if obj is already a drop target. Do not add twice! */
1858
1859 /* Is this the first? */ 1863 /* Is this the first? */
1860 EINA_LIST_FOREACH(drops, l, dropable) 1864 EINA_LIST_FOREACH(drops, l, dropable)
1861 { 1865 {
@@ -3088,7 +3092,8 @@ _wl_dropable_data_handle(Wl_Cnp_Selection *sel, char *data)
3088 if (!savedtypes.imgfile) return; 3092 if (!savedtypes.imgfile) return;
3089 3093
3090 Dropable_Cbs *cbs; 3094 Dropable_Cbs *cbs;
3091 EINA_INLIST_FOREACH(drop->cbs_list, cbs) 3095 Eina_Inlist *itr;
3096 EINA_INLIST_FOREACH_SAFE(drop->cbs_list, itr, cbs)
3092 { 3097 {
3093 /* If it's markup that also supports images */ 3098 /* If it's markup that also supports images */
3094 if ((cbs->types & ELM_SEL_FORMAT_MARKUP) && 3099 if ((cbs->types & ELM_SEL_FORMAT_MARKUP) &&
@@ -3154,6 +3159,7 @@ _wl_dropable_handle(Dropable *drop, Evas_Coord x, Evas_Coord y, Eina_Bool have_o
3154{ 3159{
3155 Dropable *last = NULL; 3160 Dropable *last = NULL;
3156 Dropable_Cbs *cbs; 3161 Dropable_Cbs *cbs;
3162 Eina_Inlist *itr;
3157 3163
3158 3164
3159 if (drop->last.in) 3165 if (drop->last.in)
@@ -3162,34 +3168,34 @@ _wl_dropable_handle(Dropable *drop, Evas_Coord x, Evas_Coord y, Eina_Bool have_o
3162 3168
3163 if ((have_obj) && (last == drop)) 3169 if ((have_obj) && (last == drop))
3164 { 3170 {
3165 EINA_INLIST_FOREACH(drop->cbs_list, cbs) 3171 EINA_INLIST_FOREACH_SAFE(drop->cbs_list, itr, cbs)
3166 if (cbs->poscb) 3172 if (cbs->poscb)
3167 cbs->poscb(cbs->posdata, drop->obj, x, y, dragaction); 3173 cbs->poscb(cbs->posdata, drop->obj, x, y, dragaction);
3168 } 3174 }
3169 else if ((have_obj) && (!last)) 3175 else if ((have_obj) && (!last))
3170 { 3176 {
3171 EINA_INLIST_FOREACH(drop->cbs_list, cbs) 3177 EINA_INLIST_FOREACH_SAFE(drop->cbs_list, itr, cbs)
3172 if (cbs->entercb) 3178 if (cbs->entercb)
3173 cbs->entercb(cbs->enterdata, drop->obj); 3179 cbs->entercb(cbs->enterdata, drop->obj);
3174 EINA_INLIST_FOREACH(drop->cbs_list, cbs) 3180 EINA_INLIST_FOREACH_SAFE(drop->cbs_list, itr, cbs)
3175 if (cbs->poscb) 3181 if (cbs->poscb)
3176 cbs->poscb(cbs->posdata, drop->obj, x, y, dragaction); 3182 cbs->poscb(cbs->posdata, drop->obj, x, y, dragaction);
3177 } 3183 }
3178 else if ((!have_obj) && (last)) 3184 else if ((!have_obj) && (last))
3179 { 3185 {
3180 EINA_INLIST_FOREACH(drop->cbs_list, cbs) 3186 EINA_INLIST_FOREACH_SAFE(drop->cbs_list, itr, cbs)
3181 if (cbs->leavecb) 3187 if (cbs->leavecb)
3182 cbs->leavecb(cbs->leavedata, drop->obj); 3188 cbs->leavecb(cbs->leavedata, drop->obj);
3183 } 3189 }
3184 else if (have_obj) 3190 else if (have_obj)
3185 { 3191 {
3186 EINA_INLIST_FOREACH(drop->cbs_list, cbs) 3192 EINA_INLIST_FOREACH_SAFE(drop->cbs_list, itr, cbs)
3187 if (cbs->entercb) 3193 if (cbs->entercb)
3188 cbs->entercb(cbs->enterdata, drop->obj); 3194 cbs->entercb(cbs->enterdata, drop->obj);
3189 if (last) 3195 if (last)
3190 { 3196 {
3191 drop = last; 3197 drop = last;
3192 EINA_INLIST_FOREACH(drop->cbs_list, cbs) 3198 EINA_INLIST_FOREACH_SAFE(drop->cbs_list, itr, cbs)
3193 if (cbs->leavecb) 3199 if (cbs->leavecb)
3194 cbs->leavecb(cbs->leavedata, drop->obj); 3200 cbs->leavecb(cbs->leavedata, drop->obj);
3195 } 3201 }
@@ -3894,10 +3900,13 @@ elm_drop_item_container_add(Evas_Object *obj,
3894 if (elm_drop_item_container_del_internal(obj, EINA_FALSE)) 3900 if (elm_drop_item_container_del_internal(obj, EINA_FALSE))
3895 { /* Updating info of existing obj */ 3901 { /* Updating info of existing obj */
3896 st = eina_list_search_unsorted(cont_drop_tg, _drop_item_container_cmp, obj); 3902 st = eina_list_search_unsorted(cont_drop_tg, _drop_item_container_cmp, obj);
3903 if (!st) return EINA_FALSE;
3897 } 3904 }
3898 else 3905 else
3899 { 3906 {
3900 st = calloc(1, sizeof(*st)); 3907 st = calloc(1, sizeof(*st));
3908 if (!st) return EINA_FALSE;
3909
3901 st->obj = obj; 3910 st->obj = obj;
3902 cont_drop_tg = eina_list_append(cont_drop_tg, st); 3911 cont_drop_tg = eina_list_append(cont_drop_tg, st);
3903 } 3912 }
@@ -4207,10 +4216,13 @@ elm_drag_item_container_add(Evas_Object *obj, double anim_tm, double tm_to_drag,
4207 if (elm_drag_item_container_del_internal(obj, EINA_FALSE)) 4216 if (elm_drag_item_container_del_internal(obj, EINA_FALSE))
4208 { /* Updating info of existing obj */ 4217 { /* Updating info of existing obj */
4209 st = eina_list_search_unsorted(cont_drag_tg, _drag_item_container_cmp, obj); 4218 st = eina_list_search_unsorted(cont_drag_tg, _drag_item_container_cmp, obj);
4219 if (!st) return EINA_FALSE;
4210 } 4220 }
4211 else 4221 else
4212 { 4222 {
4213 st = calloc(1, sizeof(*st)); 4223 st = calloc(1, sizeof(*st));
4224 if (!st) return EINA_FALSE;
4225
4214 st->obj = obj; 4226 st->obj = obj;
4215 cont_drag_tg = eina_list_append(cont_drag_tg, st); 4227 cont_drag_tg = eina_list_append(cont_drag_tg, st);
4216 4228