Enlightenment CVS committal Author : doursse Project : e17 Module : proto/edvi
Dir : e17/proto/edvi/src/lib Modified Files: esmart_dvi.c esmart_dvi.h Log Message: * src/bin/edvi_esmart_test.c: (main): * src/lib/esmart_dvi.c: (esmart_dvi_file_set): * src/lib/esmart_dvi.h: esmart_dvi_file_set() returns a value hat indicates success or failure. Fix a leak when this function is called several times. Doc and test updated. =================================================================== RCS file: /cvs/e/e17/proto/edvi/src/lib/esmart_dvi.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- esmart_dvi.c 13 Jul 2008 10:11:57 -0000 1.6 +++ esmart_dvi.c 14 Jul 2008 13:02:10 -0000 1.7 @@ -117,29 +117,47 @@ * @param obj The Evas object * @param filename: The file name * - * Set the file name of the smart dvi object @p obj + * Set the file name of the smart dvi object @p obj. If the current + * filename and @p filename are the same, nothing is done and 1 is + * returned. If @p filename is @c NULL or empty, 0 is returned. If + * @p filename is a valid PDF document, 1 is returned, otherwise 0 + * is returned. */ -void +int esmart_dvi_file_set (Evas_Object *obj, const char *filename) { Smart_Dvi *sp; - E_SMART_OBJ_GET (sp, obj, E_OBJ_NAME); + E_SMART_OBJ_GET_RETURN (sp, obj, E_OBJ_NAME, 0); if ((filename) && (sp->filename) && - (!strcmp (filename, sp->filename))) return; + (!strcmp (filename, sp->filename))) return 1; if ((filename) && (filename[0] != 0)) { + if (sp->filename) free (sp->filename); sp->filename = strdup (filename); + if (sp->dvi_page) + edvi_page_delete (sp->dvi_page); + sp->dvi_page = NULL; + if (sp->dvi_document) edvi_document_delete (sp->dvi_document); - sp->dvi_document = edvi_document_new (sp->filename, sp->dvi_device, sp->dvi_property); + sp->dvi_document = edvi_document_new (sp->filename, + sp->dvi_device, + sp->dvi_property); + if (!sp->dvi_document) + return 0; + sp->dvi_page = edvi_page_new (sp->dvi_document); + + return 1; } + + return 0; } /** =================================================================== RCS file: /cvs/e/e17/proto/edvi/src/lib/esmart_dvi.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- esmart_dvi.h 13 Jul 2008 10:11:57 -0000 1.3 +++ esmart_dvi.h 14 Jul 2008 13:02:10 -0000 1.4 @@ -72,7 +72,7 @@ Evas_Object *esmart_dvi_add (Evas *evas); Evas_Bool esmart_dvi_init (Evas_Object *obj); -void esmart_dvi_file_set (Evas_Object *obj, const char *filename); +int esmart_dvi_file_set (Evas_Object *obj, const char *filename); const char *esmart_dvi_file_get (Evas_Object *obj); void esmart_dvi_page_set (Evas_Object *obj, int page); ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs