From fac0be64e1a0fed0b80bd2c446985e040518738c Mon Sep 17 00:00:00 2001 From: barbieri Date: Thu, 1 Apr 2010 02:17:40 +0000 Subject: [PATCH] allow changing module during runtime, don't forget about file and play state. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/emotion@47638 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/emotion_smart.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/lib/emotion_smart.c b/src/lib/emotion_smart.c index b9fe3e9..2c83c4a 100644 --- a/src/lib/emotion_smart.c +++ b/src/lib/emotion_smart.c @@ -163,7 +163,7 @@ _emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module ** static void _emotion_module_close(Emotion_Video_Module *mod, void *video) { - + if (!mod) return; if (mod->plugin->close && video) mod->plugin->close(mod, video); /* FIXME: we can't go dlclosing here as a thread still may be running from @@ -207,11 +207,20 @@ EAPI Eina_Bool emotion_object_init(Evas_Object *obj, const char *module_filename) { Smart_Data *sd; + char *file; + + if (!module_filename) return EINA_FALSE; E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0); - free(sd->file); + if ((sd->module_name) && (!strcmp(sd->module_name, module_filename))) + return EINA_TRUE; + free(sd->module_name); + sd->module_name = strdup(module_filename); + + file = sd->file; sd->file = NULL; + free(sd->title); sd->title = NULL; free(sd->progress.info); @@ -229,11 +238,16 @@ emotion_object_init(Evas_Object *obj, const char *module_filename) ecore_init(); - if ((!sd->module) || (!sd->video)) + _emotion_module_close(sd->module, sd->video); + sd->module = NULL; + sd->video = NULL; + if (!_emotion_module_open(module_filename, obj, &sd->module, &sd->video)) + return EINA_FALSE; + + if (file) { - if (!_emotion_module_open(module_filename, obj, - &sd->module, &sd->video)) - return EINA_FALSE; + emotion_object_file_set(obj, file); + free(file); } return EINA_TRUE; @@ -1304,6 +1318,7 @@ _smart_del(Evas_Object * obj) _emotion_module_close(sd->module, sd->video); evas_object_del(sd->obj); free(sd->file); + free(sd->module_name); if (sd->job) ecore_job_del(sd->job); free(sd->progress.info); free(sd->ref.file); -- 2.7.4