'everything'

- fixed serious leak in thumb_view. 
 - cleanups


SVN revision: 47848
This commit is contained in:
Hannes Janetzek 2010-04-08 22:37:50 +00:00
parent c0bb6d2148
commit 1713dfa83c
6 changed files with 203 additions and 159 deletions

View File

@ -88,7 +88,7 @@ static Eina_List *handlers = NULL;
static Evry_Selector *selector = NULL;
static const char *thumb_types = NULL;
Evry_Selector **selectors;
Evry_Selector **selectors = NULL;
const char *action_selector;
/* externally accessible functions */
@ -144,13 +144,13 @@ evry_show(E_Zone *zone, const char *params)
zone->w, zone->h);
ecore_x_window_show(input_window);
if (!e_grabinput_get(input_window, 1, input_window))
goto error;
goto error1;
win = _evry_window_new(zone);
if (!win) goto error;
if (!win) goto error2;
list = _evry_list_win_new(zone);
if (!list) goto error;
if (!list) goto error2;
list->visible = EINA_FALSE;
@ -166,9 +166,6 @@ evry_show(E_Zone *zone, const char *params)
_evry_selector_subjects_get(params);
_evry_selector_activate(selectors[0]);
selectors[0]->update_timer =
ecore_timer_add(INITIAL_MATCH_LAG, _evry_cb_update_timer, selectors[0]);
if (evry_conf->views && selector->state)
{
@ -179,7 +176,10 @@ evry_show(E_Zone *zone, const char *params)
_evry_view_show(s->view);
}
else goto error;
else goto error3;
/* selectors[0]->update_timer =
* ecore_timer_add(INITIAL_MATCH_LAG, _evry_cb_update_timer, selectors[0]); */
if (!evry_conf->hide_input)
edje_object_signal_emit(list->o_main, "e,state,entry_show", "e");
@ -212,20 +212,25 @@ evry_show(E_Zone *zone, const char *params)
return 1;
error:
if (win && selectors[0])
error3:
if (selectors && selectors[0])
_evry_selector_free(selectors[0]);
if (win && selectors[1])
if (selectors && selectors[1])
_evry_selector_free(selectors[1]);
if (win && selectors[2])
if (selectors && selectors[2])
_evry_selector_free(selectors[2]);
evry_history_unload();
error2:
if (win)
_evry_window_free(win);
if (list)
_evry_list_win_free(list);
win = NULL;
list = NULL;
error1:
ecore_x_window_free(input_window);
input_window = 0;
@ -239,15 +244,17 @@ evry_hide(void)
if (!win) return;
_evry_view_clear(selector->state);
/* _evry_view_clear(selector->state); */
list->visible = EINA_FALSE;
_evry_selector_free(selectors[0]);
_evry_selector_free(selectors[1]);
_evry_selector_free(selectors[2]);
selector = NULL;
E_FREE(selectors);
selectors = NULL;
selector = NULL;
_evry_list_win_free(list);
list = NULL;
@ -1144,6 +1151,9 @@ _evry_state_pop(Evry_Selector *sel)
EINA_LIST_FREE(s->plugins, p)
p->cleanup(p);
if (sel->aggregator)
sel->aggregator->cleanup(sel->aggregator);
E_FREE(s);
sel->states = eina_list_remove_list(sel->states, sel->states);
@ -1795,14 +1805,20 @@ _evry_matches_update(Evry_Selector *sel, int async)
_evry_plugin_select(s, s->plugin);
}
static int ref = 0;
static void
_evry_item_desel(Evry_State *s, Evry_Item *it)
{
if (!it)
it = s->cur_item;
if (s->cur_item)
{
s->cur_item->selected = EINA_FALSE;
evry_item_free(s->cur_item);
it->selected = EINA_FALSE;
evry_item_free(it);
/* printf("desel: %d, %s\n", --ref, it->label); */
}
s->cur_item = NULL;
@ -1816,7 +1832,7 @@ _evry_item_sel(Evry_State *s, Evry_Item *it)
_evry_item_desel(s, NULL);
evry_item_ref(it);
/* printf("desel: %d, %s\n", ref++, it->label); */
it->selected = EINA_TRUE;
s->cur_item = it;

View File

@ -275,27 +275,27 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, c
if (evry_conf->history_sort_mode == 0)
{
if (!input || !hi->input)
{
it->usage += hi->usage * hi->count;
}
else
{
/* higher priority for exact matches */
if (!strncmp(input, hi->input, strlen(input)))
if (!input || !hi->input)
{
it->usage += hi->usage * hi->count;
}
if (!strncmp(input, hi->input, strlen(hi->input)))
else
{
it->usage += hi->usage * hi->count;
/* higher priority for exact matches */
if (!strncmp(input, hi->input, strlen(input)))
{
it->usage += hi->usage * hi->count;
}
if (!strncmp(input, hi->input, strlen(hi->input)))
{
it->usage += hi->usage * hi->count;
}
}
if (hi->context && ctxt)
{
if (hi->context == ctxt)
it->usage += hi->usage * hi->count * 2;
}
}
if (hi->context && ctxt)
{
if (hi->context == ctxt)
it->usage += hi->usage * hi->count * 2;
}
}
else if (evry_conf->history_sort_mode == 1)
{

View File

@ -93,6 +93,18 @@ _cb_sort(const void *data1, const void *data2)
return strcasecmp(it1->label, it2->label);
}
static int refs = 0;
static inline Eina_List *
_add_item(Plugin *p, Eina_List *items, Evry_Item *it)
{
evry_item_ref(it);
items = eina_list_append(items, it);
EVRY_PLUGIN_ITEM_APPEND(p, it);
return items;
}
static int
_fetch(Evry_Plugin *plugin, const char *input)
{
@ -104,9 +116,9 @@ _fetch(Evry_Plugin *plugin, const char *input)
int i, cnt = 0;
Eina_List *items = NULL;
const char *context = NULL;
EVRY_PLUGIN_ITEMS_FREE(p);
EVRY_PLUGIN_ITEMS_FREE(p);
s = p->selector->state;
if (!s || !s->cur_plugins || !s->cur_plugins->next)
@ -137,11 +149,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
it->fuzzy_match = evry_fuzzy_match(it->label, input);
if (it->fuzzy_match || p->selector == selectors[2])
{
evry_item_ref(it);
items = eina_list_append(items, it);
EVRY_PLUGIN_ITEM_APPEND(p, it);
}
items = _add_item(p, items, it);
}
}
}
@ -160,10 +168,8 @@ _fetch(Evry_Plugin *plugin, const char *input)
if (!eina_list_data_find_list(items, ll->data))
{
it = ll->data;
evry_item_ref(it);
it->fuzzy_match = 0;
items = eina_list_append(items, it);
EVRY_PLUGIN_ITEM_APPEND(p, it);
items = _add_item(p, items, it);
}
}
}
@ -178,9 +184,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
if (evry_history_item_usage_set(p->selector->history, it, input, context) &&
(!eina_list_data_find_list(items, it)))
{
evry_item_ref(it);
items = eina_list_append(items, it);
EVRY_PLUGIN_ITEM_APPEND(p, it);
items = _add_item(p, items, it);
continue;
}
}
@ -196,9 +200,8 @@ _fetch(Evry_Plugin *plugin, const char *input)
{
if (!eina_list_data_find_list(items, it))
{
evry_item_ref(it);
it->fuzzy_match = 0;
EVRY_PLUGIN_ITEM_APPEND(p, it);
items = _add_item(p, items, it);
}
}
}

View File

@ -8,6 +8,7 @@ struct _Plugin
Evry_Plugin base;
Eina_List *apps_mime;
Eina_List *apps_all;
Eina_List *apps_hist;
const Evry_Item *candidate;
Eina_Hash *added;
};
@ -42,14 +43,13 @@ static E_Config_DD *exelist_edd = NULL;
static DIR *exe_dir = NULL;
static Eina_List *exe_list = NULL;
static Eina_List *exe_list2 = NULL;
static Eina_Hash *added = NULL;
static int _scan_idler(void *data);
static void _hash_free(void *data)
{
ITEM_APP(app, data);
evry_item_free(EVRY_ITEM(app));
}
@ -76,18 +76,13 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
if (!mime) return NULL;
p->candidate = item;
p->apps_mime = efreet_util_desktop_mime_list(mime);
desktop = e_exehist_mime_desktop_get(mime);
if (desktop)
{
efreet_desktop_ref(desktop);
p->apps_mime = eina_list_prepend(p->apps_mime, desktop);
}
p->apps_mime = eina_list_prepend(p->apps_mime, desktop);
p->added = added;
if (!p->added)
p->added = eina_hash_string_small_new(_hash_free);
added = p->added;
p->added = eina_hash_string_small_new(_hash_free);
return plugin;
}
@ -158,13 +153,6 @@ _cleanup(Evry_Plugin *plugin)
{
PLUGIN(p, plugin);
Efreet_Desktop *desktop;
char *str;
/* TODO popup end func !!!
- cleanup hash for open-with plugin */
if (added)
eina_hash_free(added);
added = NULL;
if (p->added)
eina_hash_free(p->added);
@ -174,38 +162,36 @@ _cleanup(Evry_Plugin *plugin)
EINA_LIST_FREE(p->apps_all, desktop)
efreet_desktop_free(desktop);
if (exe_dir)
{
closedir(exe_dir);
exe_dir = NULL;
}
EINA_LIST_FREE(exe_path, str)
free(str);
if (exe_scan_idler)
{
ecore_idler_del(exe_scan_idler);
exe_scan_idler = NULL;
}
EINA_LIST_FREE(exe_list, str)
free(str);
EINA_LIST_FREE(exe_list2, str)
free(str);
}
static void
_cleanup_open_with(Evry_Plugin *plugin)
{
PLUGIN(p, plugin);
Efreet_Desktop *desktop;
EVRY_PLUGIN_ITEMS_CLEAR(p);
EINA_LIST_FREE(p->apps_mime, desktop)
EINA_LIST_FREE(p->apps_hist, desktop)
efreet_desktop_free(desktop);
if (plugin->type == type_action)
{
EINA_LIST_FREE(p->apps_mime, desktop)
efreet_desktop_free(desktop);
}
else
{
char *str;
if (exe_dir)
{
closedir(exe_dir);
exe_dir = NULL;
}
EINA_LIST_FREE(exe_path, str)
free(str);
EINA_LIST_FREE(p->apps_all, desktop)
efreet_desktop_free(desktop);
if (exe_scan_idler)
{
ecore_idler_del(exe_scan_idler);
exe_scan_idler = NULL;
}
EINA_LIST_FREE(exe_list, str)
free(str);
EINA_LIST_FREE(exe_list2, str)
free(str);
}
}
static Evry_Item_App *
@ -278,7 +264,7 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match)
efreet_desktop_ref(desktop);
app = E_NEW(Evry_Item_App, 1);
if (desktop)
{
evry_item_new(EVRY_ITEM(app), EVRY_PLUGIN(p), desktop->name, _item_free);
@ -292,10 +278,6 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match)
app->desktop = desktop;
/* XXX check required ? */
if (file)
app->file = eina_stringshare_add(file);
eina_hash_add(p->added, exe, app);
if (desktop)
@ -308,12 +290,18 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match)
eina_hash_add(p->added, tmp, app);
}
}
if (file && strcmp(exe, file))
{
evry_item_ref(EVRY_ITEM(app));
eina_hash_add(p->added, file, app);
}
if (file)
{
app->file = eina_stringshare_add(file);
if (strcmp(exe, file))
{
evry_item_ref(EVRY_ITEM(app));
eina_hash_add(p->added, file, app);
}
}
EVRY_ITEM(app)->fuzzy_match = match;
EVRY_PLUGIN_ITEM_APPEND(p, app);
@ -329,19 +317,22 @@ _add_desktop_list(Plugin *p, Eina_List *apps, const char *input)
EINA_LIST_FOREACH(apps, l, desktop)
{
if (eina_list_count(EVRY_PLUGIN(p)->items) > 199) continue;
if (eina_list_count(EVRY_PLUGIN(p)->items) > 199) break;
if (!desktop->name || !desktop->exec) continue;
char *exec = strrchr(desktop->exec, '/');
if (!exec++ || !exec) exec = desktop->exec;
if (input)
{
char *exec = strrchr(desktop->exec, '/');
if (!exec++ || !exec) exec = desktop->exec;
m1 = evry_fuzzy_match(exec, input);
m2 = evry_fuzzy_match(desktop->name, input);
m1 = evry_fuzzy_match(exec, input);
m2 = evry_fuzzy_match(desktop->name, input);
if (!m1 || (m2 && m2 < m1))
m1 = m2;
if (m1) _item_add(p, desktop, NULL, m1);
if (!m1 || (m2 && m2 < m1))
m1 = m2;
}
if (!input || m1) _item_add(p, desktop, NULL, m1);
}
}
@ -395,16 +386,26 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda
Plugin *p = fdata;
Efreet_Desktop *d;
Eina_List *l;
Evry_Item_App *app;
EINA_LIST_FOREACH(he->items, l, hi)
{
if (hi->plugin != p->base.name)
continue;
if ((d = efreet_util_desktop_exec_find(key)))
_item_add(p, d, NULL, 1);
{
app = _item_add(p, d, NULL, 1);
}
else
_item_add(p, NULL, (char *) key, 1);
{
app = _item_add(p, NULL, (char *) key, 1);
if (app && app->desktop)
efreet_desktop_ref(app->desktop);
}
if (app && app->desktop)
p->apps_hist = eina_list_append(p->apps_hist, app->desktop);
}
return EINA_TRUE;
}
@ -424,15 +425,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
/* add apps for a given mimetype */
if (plugin->type == type_action)
{
if (input)
_add_desktop_list(p, p->apps_mime, input);
else
{
EINA_LIST_FOREACH(p->apps_mime, l, desktop)
_item_add(p, desktop, NULL, 1);
}
}
_add_desktop_list(p, p->apps_mime, input);
/* add apps matching input */
if (input)
@ -454,6 +447,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
efreet_desktop_free(desktop);
apps = eina_list_remove_list(apps, ll);
}
efreet_desktop_free(desktop);
}
p->apps_all = apps;
@ -464,11 +458,10 @@ _fetch(Evry_Plugin *plugin, const char *input)
/* add exe history items */
else if (!plugin->items)
{
/* l = e_exehist_list_get();
* EINA_LIST_FREE(l, file)
* _item_add(p, NULL, file, 1); */
eina_hash_foreach(evry_hist->subjects, _hist_items_add_cb, p);
if (!p->apps_hist)
eina_hash_foreach(evry_hist->subjects, _hist_items_add_cb, p);
else
_add_desktop_list(p, p->apps_hist, NULL);
}
/* add executables */
@ -728,7 +721,7 @@ _init(void)
p2 = E_NEW(Plugin, 1);
evry_plugin_new(EVRY_PLUGIN(p2), "Open With...", type_action, "FILE", "", 0, NULL, NULL,
_begin_open_with, _cleanup_open_with, _fetch, _open_with_action,
_begin_open_with, _cleanup, _fetch, _open_with_action,
_icon_get, NULL, NULL);
evry_plugin_register(EVRY_PLUGIN(p1), 1);

View File

@ -18,6 +18,8 @@ struct _Plugin
Eina_Bool command;
const char *input;
Ecore_Thread *thread;
};
struct _Data
@ -34,8 +36,8 @@ static Evry_Plugin *p2 = NULL;
static Evry_Action *act1 = NULL;
static Evry_Action *act2 = NULL;
static long thread_cnt = 0;
static long thread_last = 0;
/* static long thread_cnt = 0;
* static long thread_last = 0; */
static const char *mime_folder;
@ -166,6 +168,34 @@ _item_id(const char *path)
return s3;
}
static void
_scan_cancel_func(void *data)
{
Data *d = data;
Plugin *p = d->plugin;
int cnt = 0;
Evry_Item *item;
char *filename, *path;
Evry_Item_File *file;
EINA_LIST_FREE(d->files, item)
{
filename = item->data;
free(filename);
evry_item_free(item);
}
E_FREE(d);
if (p->directory)
eina_stringshare_del(p->directory);
EINA_LIST_FREE(p->files, file)
evry_item_free(EVRY_ITEM(file));
EVRY_PLUGIN_ITEMS_CLEAR(p);
E_FREE(p);
}
static void
_scan_end_func(void *data)
@ -176,18 +206,8 @@ _scan_end_func(void *data)
Evry_Item *item;
char *filename, *path;
if (d->id != thread_last)
{
EINA_LIST_FREE(d->files, item)
{
filename = item->data;
free(filename);
evry_item_free(item);
}
E_FREE(d);
return;
}
p->thread = NULL;
EINA_LIST_FREE(d->files, item)
{
ITEM_FILE(file, item);
@ -217,19 +237,19 @@ _scan_end_func(void *data)
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD);
}
E_FREE(d);
}
static void
_read_directory(Plugin *p)
{
thread_last = ++thread_cnt;
/* thread_last = ++thread_cnt; */
Data *d = E_NEW(Data, 1);
d->plugin = p;
d->id = thread_cnt;
ecore_thread_run(_scan_func, _scan_end_func, NULL, d);
/* d->id = thread_cnt; */
p->thread = ecore_thread_run(_scan_func, _scan_end_func, _scan_cancel_func, d);
}
static Evry_Plugin *
@ -274,17 +294,25 @@ _cleanup(Evry_Plugin *plugin)
/* if a thread for this plugin returns
it will free its data if its id is smaller
than thread_last */
thread_last = ++thread_cnt;
/* thread_last = ++thread_cnt; */
if (p->directory)
eina_stringshare_del(p->directory);
if (p->thread)
{
ecore_thread_cancel(p->thread);
}
else
{
if (p->directory)
eina_stringshare_del(p->directory);
EINA_LIST_FREE(p->files, file)
evry_item_free(EVRY_ITEM(file));
EINA_LIST_FREE(p->files, file)
evry_item_free(EVRY_ITEM(file));
EVRY_PLUGIN_ITEMS_CLEAR(p);
EVRY_PLUGIN_ITEMS_CLEAR(p);
E_FREE(p);
E_FREE(p);
}
}
static void

View File

@ -640,8 +640,12 @@ _view_clear(Evry_View *view)
Item *it;
_clear_items(v->span);
if (sd->items) eina_list_free(sd->items);
sd->items = NULL;
EINA_LIST_FREE(sd->items, it)
{
evry_item_free(it->item);
E_FREE(it);
}
if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter);
sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, v->span);