r21254 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Fri Apr 29 21:34:28 UTC 2016


Author: jghali
Date: Fri Apr 29 21:34:28 2016
New Revision: 21254

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21254
Log:
#14000: Experimental embedding of PDF and EPS triggers crash on PDF export

Modified:
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/pdflib_core.h

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21254&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Fri Apr 29 21:34:28 2016
@@ -9682,11 +9682,11 @@
 	BookMinUse = true;
 }
 
-bool PDFLibCore::PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN, const QString& Profil, bool Embedded, int Intent, ShIm& imgInfo, QByteArray* output)
+bool PDFLibCore::PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN, ShIm& imgInfo, bool &fatalError)
 {
 	if (!Options.embedPDF)
 		return false;
-
+	fatalError = false;
 	
 #ifdef HAVE_PODOFO
 	// Try to catch potential pdf parsing exceptions early
@@ -9986,9 +9986,9 @@
 	}
 	catch(PoDoFo::PdfError& e)
 	{
+		fatalError = true;
 		qDebug() << "PoDoFo error!";
 		e.PrintErrorMsg();
-		assert (false);
 		return false;
 	}
 #endif
@@ -10163,6 +10163,8 @@
 		 || (ImInfo2.Page != c->pixm.imgInfo.actualPageNumber))
 	{
 		bool imageLoaded = false;
+		bool fatalError  = false;
+		QString pdfFile = fn;
 		if ((extensionIndicatesPDF(ext) || ((extensionIndicatesEPSorPS(ext)) && (c->pixm.imgInfo.type != ImageType7))) && c->effectsInUse.count() == 0)
 		{
 			if (extensionIndicatesEPSorPS(ext))
@@ -10181,17 +10183,25 @@
 					opts.append( "-sProcessColorModel=/DeviceCMYK" ); */
 				if (convertPS2PDF(fn, tmpFile, opts) == 0)
 				{
-					imageLoaded = PDF_EmbeddedPDF(c, tmpFile, sx, sy, x, y, fromAN, Profil, Embedded, Intent, ImInfo, output);
+					imageLoaded = PDF_EmbeddedPDF(c, tmpFile, sx, sy, x, y, fromAN, ImInfo, fatalError);
 					QFile::remove(tmpFile);
 				}
+				pdfFile = tmpFile;
 			}
 			else
-				imageLoaded = PDF_EmbeddedPDF(c, fn, sx, sy, x, y, fromAN, Profil, Embedded, Intent, ImInfo, output);
+				imageLoaded = PDF_EmbeddedPDF(c, fn, sx, sy, x, y, fromAN, ImInfo, fatalError);
 			isEmbeddedPDF = true;
 			ImInfo.Page = c->pixm.imgInfo.actualPageNumber;
 		}
 		if (!imageLoaded && extensionIndicatesPDF(ext) && c->effectsInUse.count() == 0 && Options.embedPDF)
+		{
+			if (fatalError)
+			{
+				PDF_Error( tr("Failed to embed the PDF file : %1").arg(pdfFile) );
+				return false;
+			}
 			qDebug() << "Failed to embed the PDF file";
+		}
 		// no embedded PDF:
 		if (!imageLoaded)
 		{

Modified: trunk/Scribus/scribus/pdflib_core.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21254&path=/trunk/Scribus/scribus/pdflib_core.h
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.h	(original)
+++ trunk/Scribus/scribus/pdflib_core.h	Fri Apr 29 21:34:28 2016
@@ -219,7 +219,7 @@
 	void    PDF_Form(const QByteArray& im);
 	void    PDF_xForm(uint objNr, double w, double h, QByteArray im);
 	bool    PDF_Image(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN = false, const QString& Profil = "", bool Embedded = false, eRenderIntent Intent = Intent_Relative_Colorimetric, QByteArray* output = NULL);
-	bool    PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN, const QString& Profil, bool Embedded, int Intent, ShIm& imgInfo, QByteArray* output = NULL);
+	bool    PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN, ShIm& imgInfo, bool &fatalError);
 #if HAVE_PODOFO
 	void copyPoDoFoObject(const PoDoFo::PdfObject* obj, uint scObjID, QMap<PoDoFo::PdfReference, uint>& importedObjects);
 	void copyPoDoFoDirect(const PoDoFo::PdfVariant* obj, QList<PoDoFo::PdfReference>& referencedObjects, QMap<PoDoFo::PdfReference, uint>& importedObjects);




More information about the scribus-commit mailing list