forked from enlightenment/efl
parent
036f824be9
commit
a1865b0d30
|
@ -122,6 +122,7 @@ struct _Ecore_Desktop_Tree_Element
|
|||
{
|
||||
void *element; /* A pointer to the element. */
|
||||
Ecore_Desktop_Tree_Element_Type type; /* The type of the element. */
|
||||
unsigned char free : 1;
|
||||
};
|
||||
typedef struct _Ecore_Desktop_Tree_Element Ecore_Desktop_Tree_Element;
|
||||
|
||||
|
@ -244,7 +245,8 @@ extern "C"
|
|||
Ecore_Desktop_Tree *
|
||||
element);
|
||||
Ecore_Desktop_Tree *ecore_desktop_tree_add_hash(Ecore_Desktop_Tree * tree,
|
||||
Ecore_Hash * element);
|
||||
Ecore_Hash * element,
|
||||
int free);
|
||||
void ecore_desktop_tree_remove(Ecore_Desktop_Tree * tree,
|
||||
int element);
|
||||
int ecore_desktop_tree_exist(Ecore_Desktop_Tree * tree,
|
||||
|
|
|
@ -151,7 +151,7 @@ ecore_desktop_menu_for_each(void (*func)
|
|||
ecore_desktop_tree_foreach(menus, 0, _ecore_desktop_menu_make_apps,
|
||||
func);
|
||||
// FIXME: Can't free this just yet, causes major memory corruption.
|
||||
// ecore_desktop_tree_del(menus);
|
||||
ecore_desktop_tree_del(menus);
|
||||
}
|
||||
free(menu_file);
|
||||
}
|
||||
|
@ -337,6 +337,7 @@ _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,6 +356,7 @@ _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;
|
||||
for (i = element + 1; i < tree->size; i++)
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -369,6 +371,7 @@ _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
|
||||
|
@ -631,9 +634,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);
|
||||
ecore_desktop_tree_add_hash(menu, pool, 1);
|
||||
ecore_desktop_tree_add_child(menu, rules);
|
||||
ecore_desktop_tree_add_hash(menu, apps);
|
||||
ecore_desktop_tree_add_hash(menu, apps, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1467,9 +1470,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);
|
||||
generate_data.pool, 0);
|
||||
ecore_desktop_tree_add_hash(unxml_data->stack,
|
||||
generate_data.pool);
|
||||
generate_data.pool, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1586,7 +1589,7 @@ _ecore_desktop_menu_select_app(void *value, void *user_data)
|
|||
desktop->allocated = TRUE;
|
||||
if (generate_data->include)
|
||||
{
|
||||
ecore_hash_set(generate_data->apps, key, strdup(app));
|
||||
ecore_hash_set(generate_data->apps, strdup(key), strdup(app));
|
||||
#ifdef DEBUG
|
||||
printf("INCLUDING %s%s - %s\n",
|
||||
((generate_data->unallocated) ? "UNALLOCATED " : ""),
|
||||
|
|
|
@ -62,7 +62,8 @@ ecore_desktop_tree_add(Ecore_Desktop_Tree * tree, char *element)
|
|||
1) *
|
||||
sizeof
|
||||
(Ecore_Desktop_Tree_Element));
|
||||
tree->elements[tree->size].element = element;
|
||||
tree->elements[tree->size].element = strdup(element);
|
||||
tree->elements[tree->size].free = 0;
|
||||
tree->elements[tree->size++].type = ECORE_DESKTOP_TREE_ELEMENT_TYPE_STRING;
|
||||
return tree;
|
||||
}
|
||||
|
@ -106,9 +107,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;
|
||||
}
|
||||
|
||||
|
@ -133,11 +136,13 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,13 +174,14 @@ 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)
|
||||
ecore_desktop_tree_add_hash(Ecore_Desktop_Tree * tree, Ecore_Hash * element, int free)
|
||||
{
|
||||
tree->elements =
|
||||
(Ecore_Desktop_Tree_Element *) realloc(tree->elements,
|
||||
|
@ -184,6 +190,8 @@ ecore_desktop_tree_add_hash(Ecore_Desktop_Tree * tree, Ecore_Hash * element)
|
|||
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;
|
||||
}
|
||||
|
@ -195,6 +203,7 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,8 +264,10 @@ 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++;
|
||||
}
|
||||
|
@ -351,9 +362,9 @@ ecore_desktop_tree_del(Ecore_Desktop_Tree * tree)
|
|||
for (i = tree->size - 1; i >= 0; i--)
|
||||
{
|
||||
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_desktop_tree_del((Ecore_Desktop_Tree *) tree->elements[i].element);
|
||||
else if ((tree->elements[i].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_HASH) &&
|
||||
(tree->elements[i].free))
|
||||
ecore_hash_destroy((Ecore_Hash *) tree->elements[i].element);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue