emotion: use stringshare for file.

SVN revision: 60818
This commit is contained in:
Cedric BAIL 2011-06-29 13:58:42 +00:00
parent 83711f3d95
commit 59ebbdeee0
1 changed files with 20 additions and 9 deletions

View File

@ -1,6 +1,14 @@
#include "emotion_private.h" #include "emotion_private.h"
#include "Emotion.h" #include "Emotion.h"
#ifdef HAVE_EIO
# include <Eio.h>
#else
# ifdef HAVE_XATTR
# include <sys/xattr.h>
# endif
#endif
#define E_SMART_OBJ_GET(smart, o, type) \ #define E_SMART_OBJ_GET(smart, o, type) \
{ \ { \
char *_e_smart_str; \ char *_e_smart_str; \
@ -42,7 +50,7 @@ struct _Smart_Data
char *module_name; char *module_name;
char *file; const char *file;
Evas_Object *obj; Evas_Object *obj;
double ratio; double ratio;
double pos; double pos;
@ -69,6 +77,11 @@ struct _Smart_Data
int button; int button;
} spu; } spu;
#ifdef HAVE_EIO
Eio_File *load_xattr;
Eio_File *save_xattr;
#endif
Emotion_Module_Options module_options; Emotion_Module_Options module_options;
}; };
@ -275,7 +288,7 @@ EAPI Eina_Bool
emotion_object_init(Evas_Object *obj, const char *module_filename) emotion_object_init(Evas_Object *obj, const char *module_filename)
{ {
Smart_Data *sd; Smart_Data *sd;
char *file; const char *file;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0); E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
@ -317,7 +330,7 @@ emotion_object_init(Evas_Object *obj, const char *module_filename)
if (file) if (file)
{ {
emotion_object_file_set(obj, file); emotion_object_file_set(obj, file);
free(file); eina_stringshare_del(file);
} }
return EINA_TRUE; return EINA_TRUE;
@ -333,13 +346,12 @@ emotion_object_file_set(Evas_Object *obj, const char *file)
DBG("file=%s", file); DBG("file=%s", file);
if (!sd->module) return EINA_FALSE; if (!sd->module) return EINA_FALSE;
if ((file) && (sd->file) && (!strcmp(file, sd->file))) return EINA_FALSE; if ((file) && (sd->file) && (file == sd->file || !strcmp(file, sd->file))) return EINA_FALSE;
if ((file) && (file[0] != 0)) if ((file) && (file[0] != 0))
{ {
int w, h; int w, h;
free(sd->file); eina_stringshare_replace(&sd->file, file);
sd->file = strdup(file);
sd->module->file_close(sd->video); sd->module->file_close(sd->video);
evas_object_image_data_set(sd->obj, NULL); evas_object_image_data_set(sd->obj, NULL);
evas_object_image_size_set(sd->obj, 1, 1); evas_object_image_size_set(sd->obj, 1, 1);
@ -361,8 +373,7 @@ emotion_object_file_set(Evas_Object *obj, const char *file)
evas_object_image_size_set(sd->obj, 1, 1); evas_object_image_size_set(sd->obj, 1, 1);
_emotion_image_data_zero(sd->obj); _emotion_image_data_zero(sd->obj);
} }
free(sd->file); eina_stringshare_replace(&sd->file, NULL);
sd->file = NULL;
} }
return EINA_TRUE; return EINA_TRUE;
@ -1597,7 +1608,7 @@ _smart_del(Evas_Object * obj)
if (sd->video) sd->module->file_close(sd->video); if (sd->video) sd->module->file_close(sd->video);
_emotion_module_close(sd->module, sd->video); _emotion_module_close(sd->module, sd->video);
evas_object_del(sd->obj); evas_object_del(sd->obj);
free(sd->file); eina_stringshare_del(sd->file);
free(sd->module_name); free(sd->module_name);
if (sd->job) ecore_job_del(sd->job); if (sd->job) ecore_job_del(sd->job);
free(sd->progress.info); free(sd->progress.info);