forked from enlightenment/efl
I'm reverting these so that menu generation doesn't crash anymore.
SVN revision: 26118
This commit is contained in:
parent
59f86f0a78
commit
1f7e1dfa3a
|
@ -131,10 +131,8 @@ struct _Ecore_Desktop_Tree
|
|||
{
|
||||
Ecore_Desktop_Tree_Element *elements; /* An array of elements. */
|
||||
int size; /* The size of the array. */
|
||||
#if 0
|
||||
char **buffers; /* An array of pointers to the bits of data. */
|
||||
int buffers_size; /* The size of the array. */
|
||||
#endif
|
||||
Ecore_Desktop_Tree *parent; /* Parent if this is a child. */
|
||||
};
|
||||
|
||||
|
@ -247,8 +245,7 @@ extern "C"
|
|||
Ecore_Desktop_Tree *
|
||||
element);
|
||||
Ecore_Desktop_Tree *ecore_desktop_tree_add_hash(Ecore_Desktop_Tree * tree,
|
||||
Ecore_Hash * element,
|
||||
int free);
|
||||
Ecore_Hash * element);
|
||||
void ecore_desktop_tree_remove(Ecore_Desktop_Tree * tree,
|
||||
int element);
|
||||
int ecore_desktop_tree_exist(Ecore_Desktop_Tree * tree,
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
/*
|
||||
* This conforms with the freedesktop.org Desktop Menu Specification version 0.92
|
||||
*
|
||||
|
@ -150,7 +147,8 @@ ecore_desktop_menu_for_each(void (*func)
|
|||
/* create the .desktop and order files from the menu */
|
||||
ecore_desktop_tree_foreach(menus, 0, _ecore_desktop_menu_make_apps,
|
||||
func);
|
||||
ecore_desktop_tree_del(menus);
|
||||
// FIXME: Can't free this just yet, causes major memory corruption.
|
||||
// ecore_desktop_tree_del(menus);
|
||||
}
|
||||
free(menu_file);
|
||||
}
|
||||
|
@ -269,8 +267,6 @@ _ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack,
|
|||
|
||||
if (oops == 0)
|
||||
{
|
||||
#if 1
|
||||
/* FIXME: Somewhere in this code mem leaks. */
|
||||
/* Get on with it. */
|
||||
ecore_desktop_tree_foreach(menu_xml, 0, _ecore_desktop_menu_unxml,
|
||||
&data);
|
||||
|
@ -304,7 +300,6 @@ _ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack,
|
|||
printf("\n\n");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -313,14 +308,14 @@ _ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack,
|
|||
if (oops)
|
||||
{
|
||||
E_FN_DEL(ecore_desktop_tree_del, (menu_xml));
|
||||
}
|
||||
if (level == 0)
|
||||
{
|
||||
E_FN_DEL(ecore_desktop_tree_del, (merge_stack));
|
||||
}
|
||||
E_FN_DEL(ecore_desktop_tree_del, (data.stack));
|
||||
E_FREE(data.path);
|
||||
E_FREE(data.base);
|
||||
E_FN_DEL(ecore_desktop_tree_del, (data.stack));
|
||||
}
|
||||
|
||||
return menu_xml;
|
||||
}
|
||||
|
@ -339,7 +334,6 @@ _ecore_desktop_menu_unxml(const void *data, Ecore_Desktop_Tree * tree,
|
|||
tree->elements[element].type =
|
||||
ECORE_DESKTOP_TREE_ELEMENT_TYPE_NULL;
|
||||
tree->elements[element].element = NULL;
|
||||
tree->elements[element].free = 0;
|
||||
}
|
||||
else if (strcmp((char *)tree->elements[element].element, "<Menu") == 0)
|
||||
{
|
||||
|
@ -355,11 +349,9 @@ _ecore_desktop_menu_unxml(const void *data, Ecore_Desktop_Tree * tree,
|
|||
|
||||
flags = (char *)menu->elements[0].element;
|
||||
flags += 7;
|
||||
/* FIXME: Should this be here? It is done again at the end */
|
||||
tree->elements[element].element = menu;
|
||||
tree->elements[element].type =
|
||||
ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE;
|
||||
tree->elements[element].free = 1;
|
||||
for (i = element + 1; i < tree->size; i++)
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -374,7 +366,6 @@ _ecore_desktop_menu_unxml(const void *data, Ecore_Desktop_Tree * tree,
|
|||
tree->elements[i].type =
|
||||
ECORE_DESKTOP_TREE_ELEMENT_TYPE_NULL;
|
||||
tree->elements[i].element = NULL;
|
||||
tree->elements[i].free = 0;
|
||||
}
|
||||
else
|
||||
if (strcmp
|
||||
|
@ -612,7 +603,6 @@ _ecore_desktop_menu_unxml(const void *data, Ecore_Desktop_Tree * tree,
|
|||
tree->elements[element].element = menu;
|
||||
tree->elements[element].type =
|
||||
ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE;
|
||||
tree->elements[element].free = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -638,9 +628,9 @@ _ecore_desktop_menu_create_menu()
|
|||
ecore_hash_set_free_value(apps, free);
|
||||
ecore_desktop_tree_extend(menu, "<MENU < > <> <>");
|
||||
ecore_desktop_tree_extend(menu, "<MENU_PATH ");
|
||||
ecore_desktop_tree_add_hash(menu, pool, 1);
|
||||
ecore_desktop_tree_add_hash(menu, pool);
|
||||
ecore_desktop_tree_add_child(menu, rules);
|
||||
ecore_desktop_tree_add_hash(menu, apps, 1);
|
||||
ecore_desktop_tree_add_hash(menu, apps);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1474,9 +1464,9 @@ _ecore_desktop_menu_generate(const void *data, Ecore_Desktop_Tree * tree,
|
|||
{
|
||||
while (unxml_data->stack->size < level)
|
||||
ecore_desktop_tree_add_hash(unxml_data->stack,
|
||||
generate_data.pool, 0);
|
||||
generate_data.pool);
|
||||
ecore_desktop_tree_add_hash(unxml_data->stack,
|
||||
generate_data.pool, 0);
|
||||
generate_data.pool);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1484,7 +1474,6 @@ _ecore_desktop_menu_generate(const void *data, Ecore_Desktop_Tree * tree,
|
|||
ECORE_DESKTOP_TREE_ELEMENT_TYPE_HASH;
|
||||
unxml_data->stack->elements[level].element =
|
||||
generate_data.pool;
|
||||
unxml_data->stack->elements[level].free = 0;
|
||||
}
|
||||
for (i = level - 1; i >= 0; i--)
|
||||
{
|
||||
|
@ -1594,7 +1583,7 @@ _ecore_desktop_menu_select_app(void *value, void *user_data)
|
|||
desktop->allocated = TRUE;
|
||||
if (generate_data->include)
|
||||
{
|
||||
ecore_hash_set(generate_data->apps, strdup(key), strdup(app));
|
||||
ecore_hash_set(generate_data->apps, key, strdup(app));
|
||||
#ifdef DEBUG
|
||||
printf("INCLUDING %s%s - %s\n",
|
||||
((generate_data->unallocated) ? "UNALLOCATED " : ""),
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "Ecore_Desktop.h"
|
||||
|
@ -45,12 +42,10 @@ ecore_desktop_tree_new(char *buffer)
|
|||
tree = E_NEW(Ecore_Desktop_Tree, 1);
|
||||
if ((tree) && (buffer))
|
||||
{
|
||||
#if 0
|
||||
tree->buffers =
|
||||
(char **)realloc(tree->buffers,
|
||||
(tree->buffers_size + 1) * sizeof(char *));
|
||||
tree->buffers[tree->buffers_size++] = strdup(buffer);
|
||||
#endif
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
|
@ -64,8 +59,7 @@ ecore_desktop_tree_add(Ecore_Desktop_Tree * tree, char *element)
|
|||
1) *
|
||||
sizeof
|
||||
(Ecore_Desktop_Tree_Element));
|
||||
tree->elements[tree->size].element = strdup(element);
|
||||
tree->elements[tree->size].free = 1;
|
||||
tree->elements[tree->size].element = element;
|
||||
tree->elements[tree->size++].type = ECORE_DESKTOP_TREE_ELEMENT_TYPE_STRING;
|
||||
return tree;
|
||||
}
|
||||
|
@ -73,14 +67,11 @@ ecore_desktop_tree_add(Ecore_Desktop_Tree * tree, char *element)
|
|||
Ecore_Desktop_Tree *
|
||||
ecore_desktop_tree_extend(Ecore_Desktop_Tree * tree, char *element)
|
||||
{
|
||||
#if 0
|
||||
tree->buffers =
|
||||
(char **)realloc(tree->buffers,
|
||||
(tree->buffers_size + 1) * sizeof(char *));
|
||||
tree->buffers[tree->buffers_size++] = strdup(element);
|
||||
tree = ecore_desktop_tree_add(tree, tree->buffers[tree->buffers_size - 1]);
|
||||
#endif
|
||||
tree = ecore_desktop_tree_add(tree, element);
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
@ -88,17 +79,13 @@ ecore_desktop_tree_extend(Ecore_Desktop_Tree * tree, char *element)
|
|||
void
|
||||
ecore_desktop_tree_track(Ecore_Desktop_Tree * tree, void *element)
|
||||
{
|
||||
#if 0
|
||||
tree->buffers =
|
||||
(char **)realloc(tree->buffers,
|
||||
(tree->buffers_size + 1) * sizeof(char *));
|
||||
tree->buffers[tree->buffers_size++] = element;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* OK, so we need an insert after all, and it falls into the dumb category. */
|
||||
/* FIXME: Needs to handle .free */
|
||||
#if 0
|
||||
Ecore_Desktop_Tree *
|
||||
ecore_desktop_tree_insert(Ecore_Desktop_Tree * tree, int before, void *element,
|
||||
Ecore_Desktop_Tree_Element_Type type)
|
||||
|
@ -116,14 +103,11 @@ ecore_desktop_tree_insert(Ecore_Desktop_Tree * tree, int before, void *element,
|
|||
{
|
||||
tree->elements[i].element = tree->elements[i - 1].element;
|
||||
tree->elements[i].type = tree->elements[i - 1].type;
|
||||
tree->elements[i].free = tree->elements[i - 1].free;
|
||||
}
|
||||
tree->elements[before].element = element;
|
||||
tree->elements[before].type = type;
|
||||
tree->elements[before].free = free;
|
||||
return tree;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* OK, so we need a tree merge after all, and it falls into the dumb category. */
|
||||
Ecore_Desktop_Tree *
|
||||
|
@ -146,18 +130,15 @@ ecore_desktop_tree_merge(Ecore_Desktop_Tree * tree, int before,
|
|||
{
|
||||
tree->elements[i].element = tree->elements[i - size].element;
|
||||
tree->elements[i].type = tree->elements[i - size].type;
|
||||
tree->elements[i].free = tree->elements[i - size].free;
|
||||
}
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
tree->elements[before + i].element = element->elements[i].element;
|
||||
tree->elements[before + i].type = element->elements[i].type;
|
||||
tree->elements[before + i].free = element->elements[i].free;
|
||||
}
|
||||
}
|
||||
|
||||
/* Careful, this might screw up the freeing order if that is important. */
|
||||
#if 0
|
||||
size = element->buffers_size;
|
||||
if (size)
|
||||
{
|
||||
|
@ -171,7 +152,6 @@ ecore_desktop_tree_merge(Ecore_Desktop_Tree * tree, int before,
|
|||
}
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
return tree;
|
||||
}
|
||||
|
||||
|
@ -186,14 +166,13 @@ ecore_desktop_tree_add_child(Ecore_Desktop_Tree * tree,
|
|||
sizeof
|
||||
(Ecore_Desktop_Tree_Element));
|
||||
tree->elements[tree->size].element = element;
|
||||
tree->elements[tree->size].free = 1;
|
||||
tree->elements[tree->size++].type = ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE;
|
||||
element->parent = tree;
|
||||
return tree;
|
||||
}
|
||||
|
||||
Ecore_Desktop_Tree *
|
||||
ecore_desktop_tree_add_hash(Ecore_Desktop_Tree * tree, Ecore_Hash * element, int free)
|
||||
ecore_desktop_tree_add_hash(Ecore_Desktop_Tree * tree, Ecore_Hash * element)
|
||||
{
|
||||
tree->elements =
|
||||
(Ecore_Desktop_Tree_Element *) realloc(tree->elements,
|
||||
|
@ -202,8 +181,6 @@ ecore_desktop_tree_add_hash(Ecore_Desktop_Tree * tree, Ecore_Hash * element, int
|
|||
sizeof
|
||||
(Ecore_Desktop_Tree_Element));
|
||||
tree->elements[tree->size].element = element;
|
||||
if (free) tree->elements[tree->size].free = 1;
|
||||
else tree->elements[tree->size].free = 0;
|
||||
tree->elements[tree->size++].type = ECORE_DESKTOP_TREE_ELEMENT_TYPE_HASH;
|
||||
return tree;
|
||||
}
|
||||
|
@ -215,7 +192,6 @@ ecore_desktop_tree_remove(Ecore_Desktop_Tree * tree, int element)
|
|||
{
|
||||
tree->elements[element].type = ECORE_DESKTOP_TREE_ELEMENT_TYPE_NULL;
|
||||
tree->elements[element].element = NULL;
|
||||
tree->elements[element].free = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,10 +252,8 @@ ecore_desktop_tree_foreach(Ecore_Desktop_Tree * tree, int level,
|
|||
moved = 1;
|
||||
tree->elements[k].type = tree->elements[j].type;
|
||||
tree->elements[k].element = tree->elements[j].element;
|
||||
tree->elements[k].free = tree->elements[j].free;
|
||||
tree->elements[j].type = ECORE_DESKTOP_TREE_ELEMENT_TYPE_NULL;
|
||||
tree->elements[j].element = NULL;
|
||||
tree->elements[j].free = 0;
|
||||
j++;
|
||||
k++;
|
||||
}
|
||||
|
@ -373,22 +347,16 @@ ecore_desktop_tree_del(Ecore_Desktop_Tree * tree)
|
|||
|
||||
for (i = tree->size - 1; i >= 0; i--)
|
||||
{
|
||||
if (tree->elements[i].free)
|
||||
{
|
||||
if (tree->elements[i].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_STRING)
|
||||
free(tree->elements[i].element);
|
||||
else if (tree->elements[i].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE)
|
||||
ecore_desktop_tree_del((Ecore_Desktop_Tree *) tree->elements[i].element);
|
||||
if (tree->elements[i].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE)
|
||||
ecore_desktop_tree_del((Ecore_Desktop_Tree *) tree->elements[i].
|
||||
element);
|
||||
else if (tree->elements[i].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_HASH)
|
||||
ecore_hash_destroy((Ecore_Hash *) tree->elements[i].element);
|
||||
}
|
||||
}
|
||||
|
||||
E_FREE(tree->elements);
|
||||
|
||||
#if 0
|
||||
for (i = tree->buffers_size - 1; i >= 0; i--)
|
||||
E_FREE(tree->buffers[i]);
|
||||
#endif
|
||||
E_FREE(tree);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#include "Ecore_Desktop.h"
|
||||
#include "ecore_desktop_private.h"
|
||||
|
||||
|
@ -64,7 +61,6 @@ ecore_desktop_xmlame_get(char *file)
|
|||
ecore_desktop_tree_extend(tree, file);
|
||||
_ecore_desktop_xmlame_parse(tree, buffer);
|
||||
}
|
||||
free(buffer);
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
|
@ -72,7 +68,7 @@ ecore_desktop_xmlame_get(char *file)
|
|||
static char *
|
||||
_ecore_desktop_xmlame_parse(Ecore_Desktop_Tree * tree, char *buffer)
|
||||
{
|
||||
while (*buffer != '\0')
|
||||
do
|
||||
{
|
||||
char *text;
|
||||
|
||||
|
@ -90,7 +86,7 @@ _ecore_desktop_xmlame_parse(Ecore_Desktop_Tree * tree, char *buffer)
|
|||
|
||||
t = *buffer;
|
||||
*buffer = '\0';
|
||||
ecore_desktop_tree_extend(tree, text);
|
||||
ecore_desktop_tree_extend(tree, strdup(text));
|
||||
*buffer = t;
|
||||
}
|
||||
if (*buffer != '\0')
|
||||
|
@ -119,7 +115,7 @@ _ecore_desktop_xmlame_parse(Ecore_Desktop_Tree * tree, char *buffer)
|
|||
{ /* The beginning of an element. */
|
||||
Ecore_Desktop_Tree *new_tree;
|
||||
|
||||
new_tree = ecore_desktop_tree_new(NULL);
|
||||
new_tree = ecore_desktop_xmlame_new(NULL);
|
||||
if (new_tree)
|
||||
{
|
||||
ecore_desktop_tree_add_child(tree, new_tree);
|
||||
|
@ -131,6 +127,7 @@ _ecore_desktop_xmlame_parse(Ecore_Desktop_Tree * tree, char *buffer)
|
|||
}
|
||||
}
|
||||
}
|
||||
while (*buffer != '\0');
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue