Fix some crashes and a bunch of memory leaks/errors. There are still a few memory leaks originating deep within ewl somewhere. Also, if you don't open the config_inwin before closing the program, there are some errors.

This commit is contained in:
Jaime Thomas 2009-02-06 04:03:13 +00:00
parent 22a49f6d1b
commit 9ebf4666e3
7 changed files with 144 additions and 39 deletions

View File

@ -7,6 +7,7 @@ static void _button_cb_return(void *data, Evas_Object *obj,
static void _button_cb_begin(void *data, Evas_Object *obj, static void _button_cb_begin(void *data, Evas_Object *obj,
const char *emission, const char *emission,
const char *source); const char *source);
static void _page_del(void *data, Evas *e, Evas_Object *obj, void *ev);
static void _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info); static void _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info);
static int _update_capacity(void *data, int type, void *ev_data); static int _update_capacity(void *data, int type, void *ev_data);
@ -37,6 +38,21 @@ static void _page_hide_finished(void *data, Evas_Object *o,
const char *emission, const char *emission,
const char *source); const char *source);
static void
_page_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *ev __UNUSED__)
{
Ecdb_Data_Project *proj;
Ecdb_Source *src;
src = data;
proj = evas_object_data_get(obj, "proj");
if (proj)
ecdb_data_project_destroy(proj);
if (src)
ecdb_source_destroy(src);
}
static void static void
_page_hide_finished(void *data, Evas_Object *o, _page_hide_finished(void *data, Evas_Object *o,
const char *emission __UNUSED__, const char *emission __UNUSED__,
@ -178,26 +194,29 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
} }
static void static void
_combo_cb_clicked(void *data, Evas_Object *obj, void *event_info) _combo_cb_clicked(void *data, Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{ {
Evas_Object *b; Evas_Object *b;
Ecdb_Burn_Project *proj; Ecdb_Burn_Project *proj;
Ecdb_Project *base_proj; Ecdb_Project *base_proj;
Ecdb_Page *page;
int sel, i, num_speeds, speed; int sel, i, num_speeds, speed;
char buf[1024]; char buf[1024];
page = data; proj = data;
if (!page) if (!proj)
return; return;
proj = evas_object_data_get(page->data, "proj");
base_proj = ECDB_PROJECT(proj); base_proj = ECDB_PROJECT(proj);
sel = ecdb_combo_selected_get(base_proj->drive_combo); sel = ecdb_combo_selected_get(base_proj->drive_combo);
if (sel < 0) if (sel < 0)
return; return;
base_proj->drive = eina_list_nth(em->drives, sel); base_proj->drive = eina_list_nth(em->drives, sel);
/* Don't keep adding items to the combo if the drive hasn't changed */
if (base_proj->drive == ecdb_combo_data_get(proj->speed_combo));
// Update the capacity here, as our capacity could change with the drive // Update the capacity here, as our capacity could change with the drive
ecore_event_add(ECDB_FILELIST_SIZE_CHANGED, NULL, NULL, NULL); ecore_event_add(ECDB_FILELIST_SIZE_CHANGED, NULL, NULL, NULL);
num_speeds = base_proj->drive->write_speeds[0]; num_speeds = base_proj->drive->write_speeds[0];
@ -381,7 +400,7 @@ _apply_clicked(void *data, Evas_Object *obj, void *event_info)
static void static void
_proj_name(void *data, Evas *e, Evas_Object *obj, void *event_info) _proj_name(void *data, Evas *e, Evas_Object *obj, void *event_info)
{ {
const char *name; char *name;
Ecdb_Data_Project *proj; Ecdb_Data_Project *proj;
proj = data; proj = data;
@ -389,7 +408,7 @@ _proj_name(void *data, Evas *e, Evas_Object *obj, void *event_info)
if (proj->volume_id) if (proj->volume_id)
free(proj->volume_id); free(proj->volume_id);
proj->volume_id = strdup(name); proj->volume_id = name;
} }
static void static void
@ -510,6 +529,11 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
src = ecdb_source_new(); src = ecdb_source_new();
ewl_widget_data_set(proj->filelist, "source", src); ewl_widget_data_set(proj->filelist, "source", src);
/* Add a delete callback so we can correctly free data that won't get
* handled automatically
*/
evas_object_event_callback_add(page->data, EVAS_CALLBACK_DEL, _page_del,
src);
edje_object_part_geometry_get(page->data, "ecdb/burn_data/filelist", edje_object_part_geometry_get(page->data, "ecdb/burn_data/filelist",
&x, &y, &w, &h); &x, &y, &w, &h);
@ -527,7 +551,7 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
page); page);
evas_object_show(proj->capacity); evas_object_show(proj->capacity);
t = ecdb_config_inwin_add(page->data, NULL); t = ecdb_config_inwin_add(bp->ret, NULL);
b = ecdb_check_add(t, NULL); b = ecdb_check_add(t, NULL);
ecdb_check_label_set(b, "Use Joliet"); ecdb_check_label_set(b, "Use Joliet");

View File

@ -7,12 +7,22 @@ static void _button_cb_return(void *data, Evas_Object *obj,
static void _button_cb_begin(void *data, Evas_Object *obj, static void _button_cb_begin(void *data, Evas_Object *obj,
const char *emission, const char *emission,
const char *source); const char *source);
static void _combo_cb_clicked(void *data, Evas_Object *obj, static void _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info);
const char *emission,
const char *source);
static void _page_hide_finished(void *data, Evas_Object *o, static void _page_hide_finished(void *data, Evas_Object *o,
const char *emission, const char *emission,
const char *source); const char *source);
static void _page_del(void *data, Evas *e, Evas_Object *obj, void *ev);
static void
_page_del(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
void *ev __UNUSED__)
{
Ecdb_Image_Project *proj;
proj = evas_object_data_get(obj, "proj");
if (proj)
ecdb_image_project_destroy(proj);
}
static void static void
_page_hide_finished(void *data, Evas_Object *o, const char *emission __UNUSED__, _page_hide_finished(void *data, Evas_Object *o, const char *emission __UNUSED__,
@ -134,8 +144,7 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
static void static void
_combo_cb_clicked(void *data, Evas_Object *obj __UNUSED__, _combo_cb_clicked(void *data, Evas_Object *obj __UNUSED__,
const char *emission __UNUSED__, void *event_info __UNUSED__)
const char *source __UNUSED__)
{ {
Evas_Object *b; Evas_Object *b;
Ecdb_Burn_Project *bp; Ecdb_Burn_Project *bp;
@ -148,7 +157,12 @@ _combo_cb_clicked(void *data, Evas_Object *obj __UNUSED__,
if (sel < 0) if (sel < 0)
return; return;
drive = eina_list_nth(em->drives, sel); ECDB_PROJECT(bp)->drive = drive = eina_list_nth(em->drives, sel);
/* Don't keep adding items to the combo if the drive hasn't changed */
if (drive == ecdb_combo_data_get(bp->speed_combo))
return;
num_speeds = drive->write_speeds[0]; num_speeds = drive->write_speeds[0];
ecdb_combo_data_set(bp->speed_combo, drive); ecdb_combo_data_set(bp->speed_combo, drive);
for (i = 1; i < num_speeds; i++) for (i = 1; i < num_speeds; i++)
@ -199,6 +213,8 @@ ecdb_burn_image_page_show(Ecdb_Page *page)
evas_object_move(page->gui, x, y); evas_object_move(page->gui, x, y);
evas_object_resize(page->image, w, h); evas_object_resize(page->image, w, h);
edje_object_part_swallow(page->gui, "action_area", page->image); edje_object_part_swallow(page->gui, "action_area", page->image);
evas_object_event_callback_add(page->image, EVAS_CALLBACK_DEL, _page_del,
page);
edje_object_signal_callback_add(page->image, "hide,finished", edje_object_signal_callback_add(page->image, "hide,finished",
"burn_image_page", "burn_image_page",
_page_hide_finished, page->gui); _page_hide_finished, page->gui);
@ -245,8 +261,7 @@ ecdb_burn_image_page_show(Ecdb_Page *page)
{ {
b = ecdb_combo_item_add(bp->drive_combo, NULL); b = ecdb_combo_item_add(bp->drive_combo, NULL);
ecdb_combo_item_label_set(b, drive->product); ecdb_combo_item_label_set(b, drive->product);
edje_object_signal_callback_add(b, "mouse,clicked,1", "*", evas_object_smart_callback_add(b, "clicked", _combo_cb_clicked, proj);
_combo_cb_clicked, proj);
ecdb_combo_append(bp->drive_combo, b); ecdb_combo_append(bp->drive_combo, b);
evas_object_show(b); evas_object_show(b);
} }

View File

@ -8,6 +8,18 @@ static void _button_cb_begin(void *data, Evas_Object *o, const char *emission,
static void _page_hide_finished(void *data, Evas_Object *o, static void _page_hide_finished(void *data, Evas_Object *o,
const char *emission, const char *emission,
const char *source); const char *source);
static void _page_del(void *data, Evas *e, Evas_Object *obj, void *ev);
static void
_page_del(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
void *ev __UNUSED__)
{
Ecdb_Erase_Project *proj;
proj = evas_object_data_get(obj, "proj");
if (proj)
ecdb_erase_project_destroy(proj);
}
static void static void
_page_hide_finished(void *data, Evas_Object *o, _page_hide_finished(void *data, Evas_Object *o,
@ -107,6 +119,8 @@ ecdb_erase_page_show(Ecdb_Page *page)
evas_object_move(page->erase, x, y); evas_object_move(page->erase, x, y);
evas_object_resize(page->erase, w, h); evas_object_resize(page->erase, w, h);
edje_object_part_swallow(page->gui, "action_area", page->erase); edje_object_part_swallow(page->gui, "action_area", page->erase);
evas_object_event_callback_add(page->erase, EVAS_CALLBACK_DEL, _page_del,
page);
evas_object_show(page->erase); evas_object_show(page->erase);
proj = ecdb_erase_project_new(); proj = ecdb_erase_project_new();

View File

@ -10,6 +10,35 @@ static void ecdb_filelist_focus_handle(int action, Evas_Object *fl,
static void ecdb_welcome_page_hide_finished(void *data, Evas_Object *o, static void ecdb_welcome_page_hide_finished(void *data, Evas_Object *o,
const char *emission, const char *emission,
const char *source); const char *source);
static void _page_del(void *data, Evas *e, Evas_Object *obj, void *ev);
static void _filelist_del(Ewl_Widget *w, void *ev_data, void *data);
static void
_filelist_del(Ewl_Widget *w, void *ev_data __UNUSED__, void *data __UNUSED__)
{
Ewl_Filelist_Filter *f;
f = ewl_filelist_filter_get(EWL_FILELIST(w));
if (f)
{
if (f->extension)
free(f->extension);
free(f);
}
}
static void
_page_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
void *ev __UNUSED__)
{
Ecdb_Page *page;
page = data;
if (!page)
return;
free(page);
}
/* XXX These need to be fixed when Ecdb_Page become the swallow, /* XXX These need to be fixed when Ecdb_Page become the swallow,
* whereas it is the actual gui as well * whereas it is the actual gui as well
@ -245,6 +274,8 @@ ecdb_create_main_gui(void)
evas_object_resize(em->page->gui, mw, mh); evas_object_resize(em->page->gui, mw, mh);
ecore_evas_resize(em->main_win_ee, mw, mh); ecore_evas_resize(em->main_win_ee, mw, mh);
ecore_evas_size_min_set(em->main_win_ee, mw, mh); ecore_evas_size_min_set(em->main_win_ee, mw, mh);
evas_object_event_callback_add(em->page->gui, EVAS_CALLBACK_DEL, _page_del,
em->page);
evas_object_move(em->page->gui, 0, 0); evas_object_move(em->page->gui, 0, 0);
evas_object_show(em->page->gui); evas_object_show(em->page->gui);
@ -337,16 +368,18 @@ ecdb_handle_typebuf(Evas_Object *gui, Ewl_Widget *fl)
{ {
filter = calloc(sizeof(Ewl_Filelist_Filter), 1); filter = calloc(sizeof(Ewl_Filelist_Filter), 1);
} }
else
if (filter->extension)
{ {
if (strcmp(filter->extension, ext)) if (filter->extension)
{ {
FREE(filter->extension); if (strcmp(filter->extension, ext))
} {
else FREE(filter->extension);
{ }
return; else
{
return;
}
} }
} }
@ -455,6 +488,8 @@ ecdb_filelist_show(Ecdb_Page *page)
filelist = ewl_filelist_new(); filelist = ewl_filelist_new();
ewl_container_child_append(EWL_CONTAINER(embed), filelist); ewl_container_child_append(EWL_CONTAINER(embed), filelist);
ewl_callback_prepend(EWL_WIDGET(filelist), EWL_CALLBACK_DESTROY,
_filelist_del, NULL);
ewl_filelist_directory_set(EWL_FILELIST(filelist), getenv("HOME")); ewl_filelist_directory_set(EWL_FILELIST(filelist), getenv("HOME"));
ewl_widget_show(filelist); ewl_widget_show(filelist);

View File

@ -36,12 +36,8 @@ ecdb_project_init(Ecdb_Project *proj)
void void
ecdb_project_destroy(Ecdb_Project *proj) ecdb_project_destroy(Ecdb_Project *proj)
{ {
FREE(proj->drive);
if (proj->ev_handler) ecore_event_handler_del(proj->ev_handler); if (proj->ev_handler) ecore_event_handler_del(proj->ev_handler);
if (proj->pipe) ecore_pipe_del(proj->pipe); if (proj->pipe) ecore_pipe_del(proj->pipe);
if (proj->ret) evas_object_del(proj->ret);
if (proj->begin) evas_object_del(proj->begin);
if (proj->drive_combo) evas_object_del(proj->drive_combo);
printf("Destroying base project\n"); printf("Destroying base project\n");
} }
@ -91,7 +87,6 @@ void
ecdb_burn_project_destroy(Ecdb_Burn_Project *proj) ecdb_burn_project_destroy(Ecdb_Burn_Project *proj)
{ {
if (proj->files) ecdb_source_destroy(proj->files); if (proj->files) ecdb_source_destroy(proj->files);
if (proj->speed_combo) evas_object_del(proj->speed_combo);
ecdb_project_destroy(ECDB_PROJECT(proj)); ecdb_project_destroy(ECDB_PROJECT(proj));
printf("Destroying burn project\n"); printf("Destroying burn project\n");
} }
@ -135,7 +130,6 @@ ecdb_erase_project_init(Ecdb_Erase_Project *proj)
void void
ecdb_erase_project_destroy(Ecdb_Erase_Project *proj) ecdb_erase_project_destroy(Ecdb_Erase_Project *proj)
{ {
if (proj->speed) evas_object_del(proj->speed);
ecdb_project_destroy(ECDB_PROJECT(proj)); ecdb_project_destroy(ECDB_PROJECT(proj));
FREE(proj); FREE(proj);
} }
@ -217,10 +211,6 @@ ecdb_data_project_init(Ecdb_Data_Project *proj)
void void
ecdb_data_project_destroy(Ecdb_Data_Project *proj) ecdb_data_project_destroy(Ecdb_Data_Project *proj)
{ {
if (proj->capacity) evas_object_del(proj->capacity);
if (proj->settings) evas_object_del(proj->settings);
if (proj->filelist_swallow) evas_object_del(proj->filelist_swallow);
if (proj->filelist) ewl_widget_destroy(proj->filelist);
FREE(proj->volume_id); FREE(proj->volume_id);
FREE(proj->publisher_id); FREE(proj->publisher_id);
FREE(proj->data_preparer_id); FREE(proj->data_preparer_id);
@ -266,7 +256,6 @@ ecdb_image_project_init(Ecdb_Image_Project *proj)
void void
ecdb_image_project_destroy(Ecdb_Image_Project *proj) ecdb_image_project_destroy(Ecdb_Image_Project *proj)
{ {
if (proj->entry) evas_object_del(proj->entry);
ecdb_burn_project_destroy(ECDB_BURN(proj)); ecdb_burn_project_destroy(ECDB_BURN(proj));
FREE(proj); FREE(proj);
} }

View File

@ -1011,6 +1011,27 @@ ecdb_combo_data_set(Evas_Object *c, void *data)
cd->data = data; cd->data = data;
} }
void *
ecdb_combo_data_get(Evas_Object *c)
{
Combo_Data *cd;
if (!c)
{
printf("ecdb_combo_data_get: NULL object!\n");
return NULL;
}
cd = evas_object_data_get(c, "cd");
if (!cd)
{
printf("ecdb_combo_data_set: NULL data!\n");
return NULL;
}
return cd->data;
}
void void
ecdb_combo_clear(Evas_Object *c) ecdb_combo_clear(Evas_Object *c)
{ {
@ -1097,8 +1118,13 @@ _config_inwin_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
iwd = data; iwd = data;
evas_object_hide(iwd->popup); if (iwd)
evas_object_hide(iwd->back); {
if (iwd->popup)
evas_object_hide(iwd->popup);
if (iwd->back)
evas_object_hide(iwd->back);
}
} }
static void static void
@ -1177,12 +1203,13 @@ ecdb_config_inwin_show(Evas_Object *inwin)
evas_object_pass_events_set(iwd->back, 0); evas_object_pass_events_set(iwd->back, 0);
evas_object_layer_set(iwd->back, evas_object_layer_get(iwd->parent) + 1); evas_object_layer_set(iwd->back, evas_object_layer_get(iwd->parent) + 1);
evas_object_raise(iwd->back);
edje_object_signal_emit(iwd->back, "ecdb,config_inwin,back,show", "ecdb"); edje_object_signal_emit(iwd->back, "ecdb,config_inwin,back,show", "ecdb");
evas_object_pass_events_set(iwd->popup, 0); evas_object_pass_events_set(iwd->popup, 0);
evas_object_layer_set(iwd->popup, evas_object_layer_get(iwd->back) + 1); evas_object_layer_set(iwd->popup, evas_object_layer_get(iwd->back) + 1);
edje_object_signal_emit(iwd->popup, "ecdb,config_inwin,popup,show", evas_object_raise(iwd->popup);
"ecdb"); edje_object_signal_emit(iwd->popup, "ecdb,config_inwin,popup,show", "ecdb");
iwd->visible = 1; iwd->visible = 1;
} }

View File

@ -44,6 +44,7 @@ void ecdb_combo_header_create_set(Evas_Object *c, void
int idx)); int idx));
int ecdb_combo_selected_get(Evas_Object *c); int ecdb_combo_selected_get(Evas_Object *c);
void ecdb_combo_data_set(Evas_Object *c, void *data); void ecdb_combo_data_set(Evas_Object *c, void *data);
void *ecdb_combo_data_get(Evas_Object *c);
void ecdb_combo_clear(Evas_Object *c); void ecdb_combo_clear(Evas_Object *c);
Evas_Object *ecdb_label_add(Evas_Object *parent, const char *name); Evas_Object *ecdb_label_add(Evas_Object *parent, const char *name);