+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
#include <Elementary.h>
#include <Elementary_Cursor.h>
+
#include "elm_priv.h"
typedef struct _Elm_Store_Filesystem Elm_Store_Filesystem;
if (!sti->fetched)
{
eina_lock_release(&sti->lock);
- if (sti->fetch_th)
- {
- ecore_thread_cancel(sti->fetch_th);
- sti->fetch_th = NULL;
- }
+ ELM_SAFE_FREE(sti->fetch_th, ecore_thread_cancel);
eina_lock_take(&sti->lock);
}
sti->fetched = EINA_FALSE;
}
static void
-_store_genlist_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+_store_genlist_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Elm_Store *st = data;
st->genlist = NULL;
- if (st->list_th)
- {
- ecore_thread_cancel(st->list_th);
- st->list_th = NULL;
- }
+ ELM_SAFE_FREE(st->list_th, ecore_thread_cancel);
st->realized = eina_list_free(st->realized);
while (st->items)
{
Elm_Store_Item *sti = (Elm_Store_Item *)st->items;
- if (sti->eval_job)
- {
- ecore_job_del(sti->eval_job);
- sti->eval_job = NULL;
- }
- if (sti->fetch_th)
- {
- ecore_thread_cancel(sti->fetch_th);
- sti->fetch_th = NULL;
- }
+ ELM_SAFE_FREE(sti->eval_job, ecore_job_del);
+ ELM_SAFE_FREE(sti->fetch_th, ecore_thread_cancel);
if (sti->store->item.free) sti->store->item.free(sti);
eina_lock_take(&sti->lock);
if (sti->data)
}
eina_lock_release(&sti->lock);
eina_lock_free(&sti->lock);
- st->items = NULL;
+ st->items = eina_inlist_remove(st->items, EINA_INLIST_GET(sti));
free(sti);
}
// FIXME: kill threads and more
////// **** WARNING ***********************************************************
//// * This function runs inside a thread outside efl mainloop. Be careful! *
// ************************************************************************
-/* TODO: refactor lock part into core? this does not depend on filesystm part */
+/* TODO: refactor lock part into core? this does not depend on filesystem part */
static void
-_store_filesystem_fetch_do(void *data, Ecore_Thread *th __UNUSED__)
+_store_filesystem_fetch_do(void *data, Ecore_Thread *th EINA_UNUSED)
{
Elm_Store_Item *sti = data;
eina_lock_take(&sti->lock);
// ************************************************************************
//// * End of separate thread function. *
////// ************************************************************************
-/* TODO: refactor lock part into core? this does not depend on filesystm part */
+/* TODO: refactor lock part into core? this does not depend on filesystem part */
static void
_store_filesystem_fetch_end(void *data, Ecore_Thread *th)
{
if (th == sti->fetch_th) sti->fetch_th = NULL;
}
-/* TODO: refactor lock part into core? this does not depend on filesystm part */
+/* TODO: refactor lock part into core? this does not depend on filesystem part */
static void
_store_filesystem_fetch_cancel(void *data, Ecore_Thread *th)
{
}
else
{
- if (sti->fetch_th)
- {
- ecore_thread_cancel(sti->fetch_th);
- sti->fetch_th = NULL;
- }
+ ELM_SAFE_FREE(sti->fetch_th, ecore_thread_cancel);
_store_cache_trim(sti->store);
}
}
static void
-_store_genlist_item_realized(void *data, Evas_Object *obj __UNUSED__, void *event_info)
+_store_genlist_item_realized(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Store *st = data;
Elm_Object_Item *gli = event_info;
if (!sti) return;
st->realized_count++;
sti->live = EINA_TRUE;
- if (sti->eval_job) ecore_job_del(sti->eval_job);
+ ecore_job_del(sti->eval_job);
sti->eval_job = ecore_job_add(_store_item_eval, sti);
}
static void
-_store_genlist_item_unrealized(void *data, Evas_Object *obj __UNUSED__, void *event_info)
+_store_genlist_item_unrealized(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Store *st = data;
Elm_Object_Item *gli = event_info;
if (!sti) return;
st->realized_count--;
sti->live = EINA_FALSE;
- if (sti->eval_job) ecore_job_del(sti->eval_job);
+ ecore_job_del(sti->eval_job);
sti->eval_job = ecore_job_add(_store_item_eval, sti);
}
}
static char *
-_store_item_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part)
+_store_item_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part)
{
Elm_Store_Item *sti = data;
const char *s = "";
}
static void
-_store_item_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
+_store_item_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
{
}
}
static void
-_store_filesystem_list_do(void *data, Ecore_Thread *th __UNUSED__)
+_store_filesystem_list_do(void *data, Ecore_Thread *th EINA_UNUSED)
{
Elm_Store_Filesystem *st = data;
Eina_Iterator *it;
}
else
{
- if (info->base.sort_id) free(info->base.sort_id);
+ free(info->base.sort_id);
free(info);
}
if (ecore_thread_check(th)) break;
}
static void
-_store_filesystem_list_update(void *data, Ecore_Thread *th __UNUSED__, void *msg)
+_store_filesystem_list_update(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
{
Elm_Store *st = data;
Elm_Store_Item_Filesystem *sti;
NULL/* func data */);
st->items = eina_inlist_append(st->items, (Eina_Inlist *)sti);
done:
- if (info->base.sort_id) free(info->base.sort_id);
+ free(info->base.sort_id);
free(info);
}
{
void (*item_free)(Elm_Store_Item *);
if (!EINA_MAGIC_CHECK(st, ELM_STORE_MAGIC)) return;
- if (st->list_th)
- {
- ecore_thread_cancel(st->list_th);
- st->list_th = NULL;
- }
+ ELM_SAFE_FREE(st->list_th, ecore_thread_cancel);
st->realized = eina_list_free(st->realized);
item_free = st->item.free;
while (st->items)
{
Elm_Store_Item *sti = (Elm_Store_Item *)st->items;
- if (sti->eval_job)
- {
- ecore_job_del(sti->eval_job);
- sti->eval_job = NULL;
- }
- if (sti->fetch_th)
- {
- ecore_thread_cancel(sti->fetch_th);
- sti->fetch_th = NULL;
- }
+ ELM_SAFE_FREE(sti->eval_job, ecore_job_del);
+ ELM_SAFE_FREE(sti->fetch_th, ecore_thread_cancel);
if (item_free) item_free(sti);
eina_lock_take(&sti->lock);
if (sti->data)
}
eina_lock_release(&sti->lock);
eina_lock_free(&sti->lock);
+ st->items = eina_inlist_remove(st->items, EINA_INLIST_GET(sti));
free(sti);
}
if (st->genlist)
Elm_Store_Filesystem *st = (Elm_Store_Filesystem *)store;
if (!EINA_MAGIC_CHECK(store, ELM_STORE_MAGIC)) return;
if (!EINA_MAGIC_CHECK(st, ELM_STORE_FILESYSTEM_MAGIC)) return;
- if (store->list_th)
- {
- ecore_thread_cancel(store->list_th);
- store->list_th = NULL;
- }
+ ELM_SAFE_FREE(store->list_th, ecore_thread_cancel);
if (!eina_stringshare_replace(&st->dir, dir)) return;
store->list_th = ecore_thread_feedback_run(_store_filesystem_list_do,
_store_filesystem_list_update,