Enlightenment CVS committal Author : doursse Project : e17 Module : proto/epdf
Dir : e17/proto/epdf/src/lib Modified Files: esmart_pdf.c esmart_pdf.h Log Message: * src/bin/epdf_esmart_test.c: (main): * src/lib/esmart_pdf.c: (esmart_pdf_file_set): * src/lib/esmart_pdf.h: esmart_pdf_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/epdf/src/lib/esmart_pdf.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- esmart_pdf.c 13 Jul 2008 09:27:35 -0000 1.10 +++ esmart_pdf.c 14 Jul 2008 13:01:28 -0000 1.11 @@ -115,33 +115,50 @@ * @param obj The Evas object * @param filename: The file name * - * Set the file name of the smart pdf object @p obj + * Set the file name of the smart pdf 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_pdf_file_set (Evas_Object *obj, const char *filename) { Smart_Pdf *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->pdf_document) - epdf_document_delete (sp->pdf_document); - if (sp->pdf_index) epdf_index_delete (sp->pdf_index); + sp->pdf_index = NULL; + + if (sp->pdf_page) + epdf_page_delete (sp->pdf_page); + sp->pdf_page = NULL; + + if (sp->pdf_document) + epdf_document_delete (sp->pdf_document); sp->pdf_document = epdf_document_new (sp->filename); + if (!sp->pdf_document) + return 0; + sp->pdf_page = epdf_page_new (sp->pdf_document); sp->pdf_index = epdf_index_new (sp->pdf_document); + + return 1; } + + return 0; } /** =================================================================== RCS file: /cvs/e/e17/proto/epdf/src/lib/esmart_pdf.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- esmart_pdf.h 21 May 2008 13:07:08 -0000 1.9 +++ esmart_pdf.h 14 Jul 2008 13:01:28 -0000 1.10 @@ -72,7 +72,7 @@ Evas_Object *esmart_pdf_add (Evas *evas); Evas_Bool esmart_pdf_init (Evas_Object *obj); -void esmart_pdf_file_set (Evas_Object *obj, const char *filename); +int esmart_pdf_file_set (Evas_Object *obj, const char *filename); const char *esmart_pdf_file_get (Evas_Object *obj); void esmart_pdf_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