forked from enlightenment/efl
memory corruption.. well just not cleaning up things in the cache hash... fix
fix... :) SVN revision: 7273
This commit is contained in:
parent
8f44a89a94
commit
3b449e38cb
|
@ -1,21 +1,5 @@
|
||||||
#include "edje.h"
|
#include "edje.h"
|
||||||
|
|
||||||
static int main_start(int argc, char **argv);
|
|
||||||
static void main_stop(void);
|
|
||||||
static void main_resize(Ecore_Evas *ee);
|
|
||||||
static int main_signal_exit(void *data, int ev_type, void *ev);
|
|
||||||
static void main_delete_request(Ecore_Evas *ee);
|
|
||||||
static void main_pre_rend(Ecore_Evas *ee);
|
|
||||||
static void main_post_rend(Ecore_Evas *ee);
|
|
||||||
|
|
||||||
void bg_setup(void);
|
|
||||||
void bg_resize(double w, double h);
|
|
||||||
static void bg_key_down(void *data, Evas * e, Evas_Object * obj, void *event_info);
|
|
||||||
|
|
||||||
void test_list(char *file);
|
|
||||||
void test_setup(char *file, char *name);
|
|
||||||
void test_reize(double w, double h);
|
|
||||||
|
|
||||||
typedef struct _Demo_Edje Demo_Edje;
|
typedef struct _Demo_Edje Demo_Edje;
|
||||||
|
|
||||||
struct _Demo_Edje
|
struct _Demo_Edje
|
||||||
|
@ -29,26 +13,46 @@ struct _Demo_Edje
|
||||||
Evas_Object *title_clip;
|
Evas_Object *title_clip;
|
||||||
Evas_Object *image;
|
Evas_Object *image;
|
||||||
double minw, minh;
|
double minw, minh;
|
||||||
int down_top : 1;
|
|
||||||
int down_bottom : 1;
|
|
||||||
int hdir;
|
int hdir;
|
||||||
int vdir;
|
int vdir;
|
||||||
|
char down_top : 1;
|
||||||
|
char down_bottom : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _Collection Collection;
|
typedef struct _Collection Collection;
|
||||||
|
|
||||||
struct _Collection
|
struct _Collection
|
||||||
{
|
{
|
||||||
|
char header : 1;
|
||||||
|
char clicked : 1;
|
||||||
|
double maxw;
|
||||||
char *file;
|
char *file;
|
||||||
char *part;
|
char *part;
|
||||||
Evas_Object *text;
|
Evas_Object *text;
|
||||||
Evas_Object *bg;
|
Evas_Object *bg;
|
||||||
|
Evas_List *entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int main_start(int argc, char **argv);
|
||||||
|
static void main_stop(void);
|
||||||
|
static void main_resize(Ecore_Evas *ee);
|
||||||
|
static int main_signal_exit(void *data, int ev_type, void *ev);
|
||||||
|
static void main_delete_request(Ecore_Evas *ee);
|
||||||
|
static void main_pre_rend(Ecore_Evas *ee);
|
||||||
|
static void main_post_rend(Ecore_Evas *ee);
|
||||||
|
|
||||||
|
void bg_setup(void);
|
||||||
|
void bg_resize(double w, double h);
|
||||||
|
static void bg_key_down(void *data, Evas * e, Evas_Object * obj, void *event_info);
|
||||||
|
|
||||||
|
void test_list_move(Collection *co_head);
|
||||||
|
void test_list(char *file);
|
||||||
|
void test_setup(char *file, char *name);
|
||||||
|
void test_reize(double w, double h);
|
||||||
|
|
||||||
static Evas_List *edjes = NULL;
|
static Evas_List *edjes = NULL;
|
||||||
static Evas_Object *o_bg = NULL;
|
static Evas_Object *o_bg = NULL;
|
||||||
static Evas_Object *o_shadow = NULL;
|
static Evas_Object *o_shadow = NULL;
|
||||||
static Evas_List *collections = NULL;
|
|
||||||
|
|
||||||
double start_time = 0.0;
|
double start_time = 0.0;
|
||||||
Ecore_Evas *ecore_evas = NULL;
|
Ecore_Evas *ecore_evas = NULL;
|
||||||
|
@ -116,13 +120,13 @@ main_delete_request(Ecore_Evas *ee)
|
||||||
static void
|
static void
|
||||||
main_pre_rend(Ecore_Evas *ee)
|
main_pre_rend(Ecore_Evas *ee)
|
||||||
{
|
{
|
||||||
// edje_thaw();
|
edje_thaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
main_post_rend(Ecore_Evas *ee)
|
main_post_rend(Ecore_Evas *ee)
|
||||||
{
|
{
|
||||||
// edje_freeze();
|
edje_freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -397,28 +401,146 @@ bottom_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
Collection *co;
|
||||||
|
|
||||||
|
co = data;
|
||||||
|
evas_object_image_file_set(co->bg, DAT"data/test/images/item_selected.png", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
Collection *co;
|
||||||
|
|
||||||
|
co = data;
|
||||||
|
evas_object_image_file_set(co->bg, DAT"data/test/images/item_normal.png", NULL);
|
||||||
|
test_setup(co->file, co->part);
|
||||||
|
evas_object_color_set(co->bg, 255, 255, 255, 128);
|
||||||
|
evas_object_color_set(co->text, 0, 0, 0, 128);
|
||||||
|
evas_object_pass_events_set(co->bg, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_head_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
Collection *co;
|
||||||
|
|
||||||
|
co = data;
|
||||||
|
co->clicked = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_head_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
Collection *co;
|
||||||
|
|
||||||
|
co = data;
|
||||||
|
co->clicked = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_head_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
Collection *co;
|
||||||
|
double x, y;
|
||||||
|
Evas_Event_Mouse_Move *ev;
|
||||||
|
|
||||||
|
co = data;
|
||||||
|
if (!co->clicked) return;
|
||||||
|
ev = event_info;
|
||||||
|
evas_object_geometry_get(co->bg, &x, &y, NULL, NULL);
|
||||||
|
x += ev->cur.canvas.x - ev->prev.canvas.x;
|
||||||
|
y += ev->cur.canvas.y - ev->prev.canvas.y;
|
||||||
|
evas_object_move(co->bg, x, y);
|
||||||
|
test_list_move(co);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cb (void *data, Evas_Object *o, const char *sig, const char *src)
|
cb (void *data, Evas_Object *o, const char *sig, const char *src)
|
||||||
{
|
{
|
||||||
// printf("CALLBACK for %p %p \"%s\" \"%s\"\n", data, o, sig, src);
|
// printf("CALLBACK for %p %p \"%s\" \"%s\"\n", data, o, sig, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test_list_move(Collection *co_head)
|
||||||
|
{
|
||||||
|
Evas_List *l;
|
||||||
|
double x, y;
|
||||||
|
|
||||||
|
evas_object_geometry_get(co_head->bg, &x, &y, NULL, NULL);
|
||||||
|
for (l = co_head->entries; l; l = l->next)
|
||||||
|
{
|
||||||
|
Collection *co;
|
||||||
|
double w, h;
|
||||||
|
|
||||||
|
co = l->data;
|
||||||
|
evas_object_geometry_get(co->text, NULL, NULL, &w, &h);
|
||||||
|
evas_object_resize(co->bg, co_head->maxw + 20, h + 10 + 10);
|
||||||
|
evas_object_image_fill_set(co->bg, 0, 0, co_head->maxw + 20, h + 10 + 10);
|
||||||
|
evas_object_move(co->bg, x, y);
|
||||||
|
evas_object_move(co->text, x + 10, y + ((h + 10 + 10 - h) / 2));
|
||||||
|
evas_object_show(co->bg);
|
||||||
|
evas_object_show(co->text);
|
||||||
|
y += h + 10 + 10 - 4 - 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_list(char *file)
|
test_list(char *file)
|
||||||
{
|
{
|
||||||
Evas_List *entries;
|
Evas_List *entries;
|
||||||
|
double maxw = 128;
|
||||||
|
Collection *co_head;
|
||||||
|
Evas_List *collections = NULL;
|
||||||
|
|
||||||
/* FIXME: still working on this */
|
|
||||||
entries = edje_file_collection_list(file);
|
entries = edje_file_collection_list(file);
|
||||||
|
{
|
||||||
|
Collection *co;
|
||||||
|
Evas_Object *o;
|
||||||
|
double w, h;
|
||||||
|
char buf[1024];
|
||||||
|
|
||||||
|
co = calloc(1, sizeof(Collection));
|
||||||
|
collections = evas_list_append(collections, co);
|
||||||
|
co->file = strdup(file);
|
||||||
|
co->part = NULL;
|
||||||
|
co->header = 1;
|
||||||
|
|
||||||
|
o = evas_object_image_add(evas);
|
||||||
|
evas_object_layer_set(o, 10);
|
||||||
|
evas_object_image_border_set(o, 10, 10, 10, 10);
|
||||||
|
evas_object_image_file_set(o, DAT"data/test/images/item_title.png", NULL);
|
||||||
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, list_head_down_cb, co);
|
||||||
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, list_head_up_cb, co);
|
||||||
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, list_head_move_cb, co);
|
||||||
|
co->bg = o;
|
||||||
|
|
||||||
|
o = evas_object_text_add(evas);
|
||||||
|
evas_object_layer_set(o, 10);
|
||||||
|
evas_object_color_set(o, 0, 0, 0, 255);
|
||||||
|
snprintf(buf, sizeof(buf), "Collections: %s", file);
|
||||||
|
evas_object_text_text_set(o, buf);
|
||||||
|
evas_object_text_font_set(o, "Vera", 6);
|
||||||
|
evas_object_pass_events_set(o, 1);
|
||||||
|
evas_object_geometry_get(o, NULL, NULL, &w, &h);
|
||||||
|
if (w > maxw) maxw = w;
|
||||||
|
co->text = o;
|
||||||
|
co_head = co;
|
||||||
|
}
|
||||||
if (entries)
|
if (entries)
|
||||||
{
|
{
|
||||||
Evas_List *l;
|
Evas_List *l;
|
||||||
|
double x = 0, y = 0;
|
||||||
|
|
||||||
for (l = entries; l; l = l->next)
|
for (l = entries; l; l = l->next)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
Collection *co;
|
Collection *co;
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
|
double w, h;
|
||||||
|
|
||||||
name = l->data;
|
name = l->data;
|
||||||
co = calloc(1, sizeof(Collection));
|
co = calloc(1, sizeof(Collection));
|
||||||
|
@ -428,8 +550,10 @@ test_list(char *file)
|
||||||
|
|
||||||
o = evas_object_image_add(evas);
|
o = evas_object_image_add(evas);
|
||||||
evas_object_layer_set(o, 10);
|
evas_object_layer_set(o, 10);
|
||||||
evas_object_image_border_set(o, 8, 8, 8, 8);
|
evas_object_image_border_set(o, 10, 10, 10, 10);
|
||||||
evas_object_image_file_set(o, DAT"data/test/images/list_norm.png", NULL);
|
evas_object_image_file_set(o, DAT"data/test/images/item_normal.png", NULL);
|
||||||
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, list_down_cb, co);
|
||||||
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, list_up_cb, co);
|
||||||
co->bg = o;
|
co->bg = o;
|
||||||
|
|
||||||
o = evas_object_text_add(evas);
|
o = evas_object_text_add(evas);
|
||||||
|
@ -438,9 +562,14 @@ test_list(char *file)
|
||||||
evas_object_text_text_set(o, co->part);
|
evas_object_text_text_set(o, co->part);
|
||||||
evas_object_text_font_set(o, "Vera", 6);
|
evas_object_text_font_set(o, "Vera", 6);
|
||||||
evas_object_pass_events_set(o, 1);
|
evas_object_pass_events_set(o, 1);
|
||||||
|
evas_object_geometry_get(o, NULL, NULL, &w, &h);
|
||||||
|
if (w > maxw) maxw = w;
|
||||||
co->text = o;
|
co->text = o;
|
||||||
}
|
}
|
||||||
edje_file_collection_list_free(entries);
|
edje_file_collection_list_free(entries);
|
||||||
|
co_head->maxw = maxw;
|
||||||
|
co_head->entries = collections;
|
||||||
|
test_list_move(co_head);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,16 @@ edje_object_file_set(Evas_Object *obj, const char *file, const char *part)
|
||||||
if (((ed->path) && (!strcmp(file, ed->path))) &&
|
if (((ed->path) && (!strcmp(file, ed->path))) &&
|
||||||
(ed->part) && (!strcmp(part, ed->part)))
|
(ed->part) && (!strcmp(part, ed->part)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_edje_file_del(ed);
|
_edje_file_del(ed);
|
||||||
|
|
||||||
if (ed->path) free(ed->path);
|
if (ed->path) free(ed->path);
|
||||||
ed->path = strdup(file);
|
ed->path = strdup(file);
|
||||||
if (ed->part) free(ed->part);
|
if (ed->part) free(ed->part);
|
||||||
ed->part = strdup(part);
|
ed->part = strdup(part);
|
||||||
|
|
||||||
_edje_file_add(ed);
|
_edje_file_add(ed);
|
||||||
|
|
||||||
if (ed->collection)
|
if (ed->collection)
|
||||||
{
|
{
|
||||||
Evas_List *l;
|
Evas_List *l;
|
||||||
|
@ -197,6 +201,10 @@ edje_file_collection_list(const char *file)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
eet_close(ef);
|
eet_close(ef);
|
||||||
|
ed_file->path = strdup(file);
|
||||||
|
ed_file->collection_hash = NULL;
|
||||||
|
ed_file->references = 1;
|
||||||
|
_edje_file_hash = evas_hash_add(_edje_file_hash, ed_file->path, ed_file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ed_file->references++;
|
ed_file->references++;
|
||||||
|
@ -237,9 +245,7 @@ _edje_file_add(Edje *ed)
|
||||||
|
|
||||||
ed->file = evas_hash_find(_edje_file_hash, ed->path);
|
ed->file = evas_hash_find(_edje_file_hash, ed->path);
|
||||||
if (ed->file)
|
if (ed->file)
|
||||||
{
|
|
||||||
ed->file->references++;
|
ed->file->references++;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ef = eet_open(ed->path, EET_FILE_MODE_READ);
|
ef = eet_open(ed->path, EET_FILE_MODE_READ);
|
||||||
|
@ -256,13 +262,7 @@ _edje_file_add(Edje *ed)
|
||||||
ed->file = NULL;
|
ed->file = NULL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!ed->file->collection_dir)
|
_edje_file_hash = evas_hash_add(_edje_file_hash, ed->file->path, ed->file);
|
||||||
{
|
|
||||||
_edje_file_free(ed->file);
|
|
||||||
ed->file = NULL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
_edje_file_hash = evas_hash_add(_edje_file_hash, ed->path, ed->file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ed->collection = evas_hash_find(ed->file->collection_hash, ed->part);
|
ed->collection = evas_hash_find(ed->file->collection_hash, ed->part);
|
||||||
|
@ -290,7 +290,6 @@ _edje_file_add(Edje *ed)
|
||||||
snprintf(buf, sizeof(buf), "collections/%i", id);
|
snprintf(buf, sizeof(buf), "collections/%i", id);
|
||||||
if (!ef) eet_open(ed->path, EET_FILE_MODE_READ);
|
if (!ef) eet_open(ed->path, EET_FILE_MODE_READ);
|
||||||
if (!ef) goto out;
|
if (!ef) goto out;
|
||||||
/* collection leaks? */
|
|
||||||
ed->collection = eet_data_read(ef,
|
ed->collection = eet_data_read(ef,
|
||||||
_edje_edd_edje_part_collection,
|
_edje_edd_edje_part_collection,
|
||||||
buf);
|
buf);
|
||||||
|
@ -300,8 +299,6 @@ _edje_file_add(Edje *ed)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ed->file->references--;
|
|
||||||
if (ed->file->references <= 0)
|
|
||||||
_edje_file_free(ed->file);
|
_edje_file_free(ed->file);
|
||||||
ed->file = NULL;
|
ed->file = NULL;
|
||||||
}
|
}
|
||||||
|
@ -320,13 +317,14 @@ _edje_file_del(Edje *ed)
|
||||||
{
|
{
|
||||||
ed->collection->references--;
|
ed->collection->references--;
|
||||||
if (ed->collection->references <= 0)
|
if (ed->collection->references <= 0)
|
||||||
|
{
|
||||||
|
ed->file->collection_hash = evas_hash_del(ed->file->collection_hash, ed->part, ed->collection);
|
||||||
_edje_collection_free(ed->collection);
|
_edje_collection_free(ed->collection);
|
||||||
|
}
|
||||||
ed->collection = NULL;
|
ed->collection = NULL;
|
||||||
}
|
}
|
||||||
if (ed->file)
|
if (ed->file)
|
||||||
{
|
{
|
||||||
ed->file->references--;
|
|
||||||
if (ed->file->references <= 0)
|
|
||||||
_edje_file_free(ed->file);
|
_edje_file_free(ed->file);
|
||||||
ed->file = NULL;
|
ed->file = NULL;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +337,7 @@ _edje_file_del(Edje *ed)
|
||||||
rp = ed->parts->data;
|
rp = ed->parts->data;
|
||||||
ed->parts = evas_list_remove(ed->parts, rp);
|
ed->parts = evas_list_remove(ed->parts, rp);
|
||||||
_edje_text_part_on_del(ed, rp);
|
_edje_text_part_on_del(ed, rp);
|
||||||
// evas_object_del(rp->object);
|
evas_object_del(rp->object);
|
||||||
if (rp->swallowed_object)
|
if (rp->swallowed_object)
|
||||||
{
|
{
|
||||||
evas_object_event_callback_del(rp->swallowed_object,
|
evas_object_event_callback_del(rp->swallowed_object,
|
||||||
|
@ -385,6 +383,11 @@ _edje_file_del(Edje *ed)
|
||||||
void
|
void
|
||||||
_edje_file_free(Edje_File *edf)
|
_edje_file_free(Edje_File *edf)
|
||||||
{
|
{
|
||||||
|
edf->references--;
|
||||||
|
if (edf->references > 0) return;
|
||||||
|
|
||||||
|
_edje_file_hash = evas_hash_del(_edje_file_hash, edf->path, edf);
|
||||||
|
|
||||||
if (edf->path) free(edf->path);
|
if (edf->path) free(edf->path);
|
||||||
if (edf->image_dir)
|
if (edf->image_dir)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue