summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-01-07 19:33:27 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-01-07 19:34:15 +0900
commit3c9cdb0cc1047743eb35e655375278cd00c615c8 (patch)
tree797f142052f2944183b186d89dc43e83d263fe9d
parentd0bbe5f6cf6c43d2dca55fdc9a61fecfca091853 (diff)
elm filesel - fix eio access of widget data after de in eio threads
@fix
-rw-r--r--src/lib/elc_fileselector.c80
1 files changed, 46 insertions, 34 deletions
diff --git a/src/lib/elc_fileselector.c b/src/lib/elc_fileselector.c
index 9a70311a6..c5d9a19bb 100644
--- a/src/lib/elc_fileselector.c
+++ b/src/lib/elc_fileselector.c
@@ -376,18 +376,20 @@ _ls_filter_cb(void *data,
376 Eina_Bool dir = EINA_FALSE; 376 Eina_Bool dir = EINA_FALSE;
377 char *pch = NULL, *temp = NULL; 377 char *pch = NULL, *temp = NULL;
378 char temp_path[EINA_PATH_MAX]; 378 char temp_path[EINA_PATH_MAX];
379 ELM_FILESELECTOR_DATA_GET(lreq->obj, sd);
379 380
380 if (!lreq->sd->hidden_visible && info->path[info->name_start] == '.') 381 if (!sd) return EINA_FALSE;
382 if (!sd->hidden_visible && info->path[info->name_start] == '.')
381 return EINA_FALSE; 383 return EINA_FALSE;
382 384
383 if (info->type == EINA_FILE_DIR) 385 if (info->type == EINA_FILE_DIR)
384 dir = EINA_TRUE; 386 dir = EINA_TRUE;
385 387
386 if (lreq->sd->only_folder && !dir) 388 if (sd->only_folder && !dir)
387 return EINA_FALSE; 389 return EINA_FALSE;
388 390
389 //Search entry filter 391 //Search entry filter
390 if ((lreq->sd->search_string) && (lreq->sd->search_string[0] != '\0')) 392 if ((sd->search_string) && (sd->search_string[0] != '\0'))
391 { 393 {
392 strcpy(temp_path, info->path); 394 strcpy(temp_path, info->path);
393 pch = strchr(temp_path, '/'); 395 pch = strchr(temp_path, '/');
@@ -397,11 +399,12 @@ _ls_filter_cb(void *data,
397 pch = strchr(pch + 1, '/'); 399 pch = strchr(pch + 1, '/');
398 } 400 }
399 temp++; 401 temp++;
400 if ((temp) && (lreq->sd->search_string) && (!strstr(temp, lreq->sd->search_string))) 402 if ((temp) && (sd->search_string) &&
403 (!strstr(temp, sd->search_string)))
401 return EINA_FALSE; 404 return EINA_FALSE;
402 } 405 }
403 406
404 cf = lreq->sd->current_filter; 407 cf = sd->current_filter;
405 if (!cf) 408 if (!cf)
406 return EINA_TRUE; 409 return EINA_TRUE;
407 410
@@ -528,13 +531,15 @@ _file_list_cmp(const void *a, const void *b)
528static void 531static void
529_signal_first(Listing_Request *lreq) 532_signal_first(Listing_Request *lreq)
530{ 533{
534 ELM_FILESELECTOR_DATA_GET(lreq->obj, sd);
535
531 if (!lreq->first) return; 536 if (!lreq->first) return;
537 if (!sd) return;
532 538
533 if (lreq->sd->multi) 539 if (sd->multi)
534 { 540 {
535 char *path; 541 char *path;
536 EINA_LIST_FREE(lreq->sd->paths, path) 542 EINA_LIST_FREE(sd->paths, path) free(path);
537 free(path);
538 } 543 }
539 544
540 evas_object_smart_callback_call 545 evas_object_smart_callback_call
@@ -542,11 +547,11 @@ _signal_first(Listing_Request *lreq)
542 547
543 if (!lreq->parent_it) 548 if (!lreq->parent_it)
544 { 549 {
545 if (lreq->sd->mode == ELM_FILESELECTOR_LIST) 550 if (sd->mode == ELM_FILESELECTOR_LIST)
546 elm_genlist_clear(lreq->sd->files_view); 551 elm_genlist_clear(sd->files_view);
547 else 552 else
548 elm_gengrid_clear(lreq->sd->files_view); 553 elm_gengrid_clear(sd->files_view);
549 eina_stringshare_replace(&lreq->sd->path, lreq->path); 554 eina_stringshare_replace(&sd->path, lreq->path);
550 _anchors_do(lreq->obj, lreq->path); 555 _anchors_do(lreq->obj, lreq->path);
551 } 556 }
552 557
@@ -561,10 +566,12 @@ _ls_main_cb(void *data,
561 Listing_Request *lreq = data; 566 Listing_Request *lreq = data;
562 Elm_Object_Item *item; 567 Elm_Object_Item *item;
563 int itcn = ELM_FILE_UNKNOW; 568 int itcn = ELM_FILE_UNKNOW;
564 569 ELM_FILESELECTOR_DATA_GET(lreq->obj, sd);
570
565 if (eio_file_check(handler)) return; 571 if (eio_file_check(handler)) return;
572 if (!sd) return;
566 573
567 if (!lreq->sd->files_view || lreq->sd->current != handler) 574 if (!sd->files_view || sd->current != handler)
568 { 575 {
569 eio_file_cancel(handler); 576 eio_file_cancel(handler);
570 return; 577 return;
@@ -581,31 +588,31 @@ _ls_main_cb(void *data,
581 itcn = ELM_FILE_IMAGE; 588 itcn = ELM_FILE_IMAGE;
582 } 589 }
583 590
584 if (lreq->sd->mode == ELM_FILESELECTOR_LIST) 591 if (sd->mode == ELM_FILESELECTOR_LIST)
585 { 592 {
586 item = elm_genlist_item_sorted_insert(lreq->sd->files_view, list_itc[itcn], 593 item = elm_genlist_item_sorted_insert(sd->files_view, list_itc[itcn],
587 eina_stringshare_add(info->path), 594 eina_stringshare_add(info->path),
588 lreq->parent_it, 595 lreq->parent_it,
589 ((lreq->sd->expand) && (itcn == ELM_DIRECTORY)) 596 ((sd->expand) && (itcn == ELM_DIRECTORY))
590 ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE, 597 ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
591 _file_list_cmp, NULL, NULL); 598 _file_list_cmp, NULL, NULL);
592 599
593 if (lreq->selected && !strcmp(info->path, lreq->selected)) 600 if (lreq->selected && !strcmp(info->path, lreq->selected))
594 { 601 {
595 elm_genlist_item_selected_set(item, EINA_TRUE); 602 elm_genlist_item_selected_set(item, EINA_TRUE);
596 elm_object_text_set(lreq->sd->name_entry, ecore_file_file_get(info->path)); 603 elm_object_text_set(sd->name_entry, ecore_file_file_get(info->path));
597 } 604 }
598 } 605 }
599 else if (lreq->sd->mode == ELM_FILESELECTOR_GRID) 606 else if (sd->mode == ELM_FILESELECTOR_GRID)
600 { 607 {
601 item = elm_gengrid_item_sorted_insert(lreq->sd->files_view, grid_itc[itcn], 608 item = elm_gengrid_item_sorted_insert(sd->files_view, grid_itc[itcn],
602 eina_stringshare_add(info->path), 609 eina_stringshare_add(info->path),
603 _file_grid_cmp, NULL, NULL); 610 _file_grid_cmp, NULL, NULL);
604 611
605 if (lreq->selected && !strcmp(info->path, lreq->selected)) 612 if (lreq->selected && !strcmp(info->path, lreq->selected))
606 { 613 {
607 elm_gengrid_item_selected_set(item, EINA_TRUE); 614 elm_gengrid_item_selected_set(item, EINA_TRUE);
608 elm_object_text_set(lreq->sd->name_entry, ecore_file_file_get(info->path)); 615 elm_object_text_set(sd->name_entry, ecore_file_file_get(info->path));
609 } 616 }
610 } 617 }
611} 618}
@@ -613,8 +620,6 @@ _ls_main_cb(void *data,
613static void 620static void
614_listing_request_cleanup(Listing_Request *lreq) 621_listing_request_cleanup(Listing_Request *lreq)
615{ 622{
616 EINA_REFCOUNT_UNREF(lreq->sd) _elm_fileselector_smart_del_do(lreq->sd);
617
618 eina_stringshare_del(lreq->path); 623 eina_stringshare_del(lreq->path);
619 eina_stringshare_del(lreq->selected); 624 eina_stringshare_del(lreq->selected);
620 free(lreq); 625 free(lreq);
@@ -624,12 +629,16 @@ static void
624_ls_done_cb(void *data, Eio_File *handler EINA_UNUSED) 629_ls_done_cb(void *data, Eio_File *handler EINA_UNUSED)
625{ 630{
626 Listing_Request *lreq = data; 631 Listing_Request *lreq = data;
632 ELM_FILESELECTOR_DATA_GET(lreq->obj, sd);
627 633
628 _signal_first(lreq); 634 _signal_first(lreq);
629 elm_progressbar_pulse(lreq->sd->spinner, EINA_FALSE); 635 if (sd)
630 elm_layout_signal_emit(lreq->obj, "elm,action,spinner,hide", "elm"); 636 {
637 elm_progressbar_pulse(sd->spinner, EINA_FALSE);
638 elm_layout_signal_emit(lreq->obj, "elm,action,spinner,hide", "elm");
639 sd->current = NULL;
640 }
631 641
632 lreq->sd->current = NULL;
633 _listing_request_cleanup(lreq); 642 _listing_request_cleanup(lreq);
634} 643}
635 644
@@ -637,12 +646,14 @@ static void
637_ls_error_cb(void *data, Eio_File *handler, int error EINA_UNUSED) 646_ls_error_cb(void *data, Eio_File *handler, int error EINA_UNUSED)
638{ 647{
639 Listing_Request *lreq = data; 648 Listing_Request *lreq = data;
649 ELM_FILESELECTOR_DATA_GET(lreq->obj, sd);
640 650
641 elm_progressbar_pulse(lreq->sd->spinner, EINA_FALSE); 651 if (sd)
642 elm_layout_signal_emit(lreq->obj, "elm,action,spinner,hide", "elm"); 652 {
643 653 elm_progressbar_pulse(sd->spinner, EINA_FALSE);
644 if (lreq->sd->current == handler) 654 elm_layout_signal_emit(lreq->obj, "elm,action,spinner,hide", "elm");
645 lreq->sd->current = NULL; 655 if (sd->current == handler) sd->current = NULL;
656 }
646 _listing_request_cleanup(lreq); 657 _listing_request_cleanup(lreq);
647} 658}
648 659
@@ -661,13 +672,12 @@ _populate(Evas_Object *obj,
661 672
662 if (sd->monitor) eio_monitor_del(sd->monitor); 673 if (sd->monitor) eio_monitor_del(sd->monitor);
663 if (sd->current) eio_file_cancel(sd->current); 674 if (sd->current) eio_file_cancel(sd->current);
675 sd->monitor = NULL;
676 sd->current = NULL;
664 677
665 lreq = malloc(sizeof (Listing_Request)); 678 lreq = malloc(sizeof (Listing_Request));
666 if (!lreq) return; 679 if (!lreq) return;
667 680
668 lreq->sd = sd;
669 EINA_REFCOUNT_REF(lreq->sd);
670
671 lreq->parent_it = parent_it; /* FIXME: should we refcount the parent_it ? */ 681 lreq->parent_it = parent_it; /* FIXME: should we refcount the parent_it ? */
672 lreq->obj = obj; 682 lreq->obj = obj;
673 lreq->path = eina_stringshare_add(path); 683 lreq->path = eina_stringshare_add(path);
@@ -1551,6 +1561,8 @@ _elm_fileselector_evas_object_smart_del(Eo *obj EINA_UNUSED, Elm_Fileselector_Da
1551 1561
1552 if (sd->monitor) eio_monitor_del(sd->monitor); 1562 if (sd->monitor) eio_monitor_del(sd->monitor);
1553 if (sd->current) eio_file_cancel(sd->current); 1563 if (sd->current) eio_file_cancel(sd->current);
1564 sd->monitor = NULL;
1565 sd->current = NULL;
1554 1566
1555 EINA_LIST_FREE(sd->handlers, h) 1567 EINA_LIST_FREE(sd->handlers, h)
1556 { 1568 {