Enlightenment CVS committal Author : onefang Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_apps.c Log Message: A little bit of clean up and some refactoring. Now every e_app_new() is checked to see if it's in a repository, and a reference is returned if it is. Looks like this fixes that E_App free problem. =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_apps.c,v retrieving revision 1.210 retrieving revision 1.211 diff -u -3 -r1.210 -r1.211 --- e_apps.c 1 Oct 2006 09:45:24 -0000 1.210 +++ e_apps.c 1 Oct 2006 12:34:57 -0000 1.211 @@ -140,6 +140,7 @@ _e_apps_repositories = evas_list_append(_e_apps_repositories, evas_stringshare_add(buf)); _e_apps_exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _e_apps_cb_exit, NULL); _e_apps_border_add_handler = ecore_event_handler_add(E_EVENT_BORDER_ADD, _e_app_cb_event_border_add, NULL); + /* Prefill with empty E_Apps from the all directory. */ ecore_desktop_instrumentation_reset(); begin = ecore_time_get(); _e_apps_all = e_app_new(_e_apps_path_all, 0); @@ -157,13 +158,9 @@ if ((app) && (app->path)) { _e_apps_every_app = evas_hash_direct_add(_e_apps_every_app, app->path, app); - /* Link it in to all if needed. */ - if (strcmp(app->path, _e_apps_path_all) != 0) - { - app->parent = _e_apps_all; - _e_apps_all->subapps = evas_list_prepend(_e_apps_all->subapps, app); - e_object_ref(E_OBJECT(app)); - } + app->parent = _e_apps_all; + _e_apps_all->subapps = evas_list_prepend(_e_apps_all->subapps, app); + e_object_ref(E_OBJECT(app)); } } ecore_list_destroy(_e_apps_all_filenames); @@ -312,9 +309,11 @@ e_app_new(const char *path, int scan_subdirs) { E_App *a; + E_App *a2; struct stat st; int stated = 0; int new_app = 0; + int virtual_app = 0; int in_all = 0; char buf[PATH_MAX]; @@ -324,13 +323,22 @@ /* Is it a virtual path from inside a .order file? */ if ((!a) && (!ecore_file_exists(path))) { - snprintf(buf, sizeof(buf), "%s/%s", _e_apps_path_all, ecore_file_get_file(path)); - if (ecore_file_exists(path)) + Evas_List *pl; + + pl = _e_apps_repositories; + while (pl) { - path = buf; - a = e_app_path_find(path); - in_all = 1; - } + _e_app_resolve_file_name(buf, sizeof(buf), (char *)pl->data, ecore_file_get_file(path)); + if (ecore_file_exists(buf)) + { + path = buf; + a = e_app_path_find(path); + in_all = 1; + virtual_app = 1; + break; + } + pl = pl->next; + } } /* Check if the cache is still valid. */ @@ -394,6 +402,29 @@ else goto error; + if (virtual_app) + { + a2 = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free); + if (a2) + { + if (_e_app_copy(a2, a)) + a->references = evas_list_append(a->references, a2); + else + { + e_object_del(E_OBJECT(a2)); + goto error; + } + } + else + goto error; + } + /* Timestamp the cache, and no need to stat the file twice if the cache was stale. */ + if ((stated) || (stat(a->path, &st) >= 0)) + { + a->mtime = st.st_mtime; + stated = 1; + } + if (new_app) { _e_apps_every_app = evas_hash_direct_add(_e_apps_every_app, a->path, a); @@ -408,13 +439,10 @@ _e_apps_all->subapps = evas_list_remove(_e_apps_all->subapps, a); if ((_e_apps_all) && (a != _e_apps_all) && (in_all)) _e_apps_all->subapps = evas_list_prepend(_e_apps_all->subapps, a); - - /* Timestamp the cache, and no need to stat the file twice if the cache was stale. */ - if ((stated) || (stat(a->path, &st) >= 0)) - { - a->mtime = st.st_mtime; - stated = 1; - } + + if (virtual_app) + a = a2; + } else goto error; @@ -515,7 +543,7 @@ a2 = NULL; _e_app_resolve_file_name(buf, sizeof(buf), a->path, s); - if (ecore_file_exists(buf)) +// if (ecore_file_exists(buf)) { a2 = e_app_new(buf, scan_subdirs); if (a2) @@ -525,6 +553,7 @@ e_object_ref(E_OBJECT(a2)); } } +#if 0 else { E_App *a3; @@ -557,6 +586,7 @@ } } } +#endif } ecore_list_destroy(files); } @@ -1717,7 +1747,7 @@ a->parent = _e_apps_all; _e_apps_all->subapps = evas_list_append(_e_apps_all->subapps, a); e_object_ref(E_OBJECT(a)); - /* FIXME: Don't know if we need to copy and reference this since it is in the repository. */ + /* FIXME: we need to copy and reference this since it is in the repository. */ _e_app_change(a, E_APP_ADD); } else @@ -2173,8 +2203,8 @@ * freed but the list entries for _e_apps_all->subapps is still there * and so u have a nasty dangling pointer to garbage memory */ - if (_e_apps_all) - _e_apps_all->subapps = evas_list_remove(_e_apps_all->subapps, a); +// if (_e_apps_all) +// _e_apps_all->subapps = evas_list_remove(_e_apps_all->subapps, a); /* END FIXME */ while (evas_list_find(_e_apps_start_pending, a)) @@ -2527,6 +2557,7 @@ subapps = evas_list_append(subapps, a2); e_object_ref(E_OBJECT(a2)); } +#if 0 else { /* We ask for a reference! */ @@ -2566,6 +2597,7 @@ } } } +#endif } } ecore_list_destroy(files); @@ -2648,12 +2680,12 @@ dst->orig = src; dst->desktop = src->desktop; + dst->path = src->path; dst->name = src->name; dst->generic = src->generic; dst->comment = src->comment; dst->exe = src->exe; dst->exe_params = src->exe_params; - dst->path = src->path; dst->win_name = src->win_name; dst->win_class = src->win_class; dst->win_title = src->win_title; ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs