elm test dnd: fix multiple items dnd
authorThiep Ha <thiepha@gmail.com>
Mon, 9 May 2016 08:10:01 +0000 (17:10 +0900)
committerThiep Ha <thiepha@gmail.com>
Mon, 9 May 2016 08:32:12 +0000 (17:32 +0900)
When we do dnd with multiple items in genlist, gengrid in dnd test,
the items are correctly transfered.
It is caused by incorrect sent data.
This patch fixes by adding new line separation between items' data.

src/bin/elementary/test_dnd.c

index 40c2c61..faeee2e 100644 (file)
@@ -65,6 +65,7 @@ _drag_data_build(Eina_List **items)
         Elm_Object_Item *it;
         const char *t;
         unsigned int len = 0;
+        int i = 0;
 
         EINA_LIST_FOREACH(*items, l, it)
           {
@@ -73,17 +74,20 @@ _drag_data_build(Eina_List **items)
                len += strlen(t);
           }
 
-        drag_data = malloc(len + eina_list_count(*items) * (FILESEP_LEN + 1) + 1);
+        drag_data = malloc(len + eina_list_count(*items) * (FILESEP_LEN + 1));
         strcpy((char *) drag_data, "");
 
-        /* drag data in form: file://URI1\nfile://URI2\n */
+        /* drag data in form: file://URI1\nfile://URI2 */
         EINA_LIST_FOREACH(*items, l, it)
           {
              t = (char *)elm_object_item_data_get(it);
              if (t)
                {
+                  if (i > 0)
+                    strcat((char *) drag_data, "\n");
                   strcat((char *) drag_data, FILESEP);
                   strcat((char *) drag_data, t);
+                  i++;
                }
           }
      }