elm: dnd: Leak less.

SVN revision: 52025
This commit is contained in:
Brett Nash 2010-09-09 05:37:02 +00:00
parent 2db7870780
commit 1b2ba6b9ed
1 changed files with 26 additions and 1 deletions

View File

@ -1,3 +1,8 @@
/*
* todo
* - move to stringshare for stuff when I can
*/
#include <stdbool.h>
#include <sys/mman.h>
@ -127,6 +132,7 @@ static int notify_handler_uri(struct _elm_cnp_selection *sel,
static struct pasteimage *pasteimage_alloc(const char *file);
static bool pasteimage_append(struct pasteimage *pi, Evas_Object *entry);
static void pasteimage_free(struct pasteimage *pi);
static struct {
const char *name;
@ -691,6 +697,8 @@ notify_handler_uri(struct _elm_cnp_selection *sel,
return 0;
}
if (savedtypes.pi) pasteimage_free(savedtypes.pi);
pi = pasteimage_alloc(p);
if (savedtypes.textreq)
@ -901,6 +909,15 @@ pasteimage_alloc(const char *file)
return pi;
}
static void
pasteimage_free(struct pasteimage *pi)
{
if (!pi) return;
if (pi->file) free(pi->file);
if (pi->tag) free(pi->tag);
free(pi);
}
static bool
pasteimage_provider_set(Evas_Object *entry)
{
@ -1187,7 +1204,9 @@ found:
ddata.data = (char *)savedtypes.pi->file;
dropable->dropcb(dropable->cbdata, dropable->obj, &ddata);
ecore_x_dnd_send_finished();
/* FIXME: Clean up pi */
pasteimage_free(savedtypes.pi);
savedtypes.pi = NULL;
return true;
}
@ -1339,6 +1358,12 @@ elm_drop_target_del(Evas_Object *obj)
ecore_event_handler_del(handler_drop);
ecore_event_handler_del(handler_enter);
if (savedtypes.pi)
{
pasteimage_free(savedtypes.pi);
savedtypes.pi = NULL;
}
return true;
}