r13764 by jghali - #8263: pdf export crash when ISO-10646-UCS-2 text codec is missing : check availability of codec right at start of export, exit immediately with an error if not found

scribus-commit scribus-commit at lists.scribus.net
Sat Jul 11 12:15:23 CEST 2009


Revision: 13764
Author: jghali
Date: 2009-07-11T10:13:23.967457Z
Commit message: #8263: pdf export crash when ISO-10646-UCS-2 text codec is missing : check availability of codec right at start of export, exit immediately with an error if not found

Changeset: 
M  /trunk/Scribus/scribus/pdflib_core.cpp
M  /trunk/Scribus/scribus/pdflib_core.h

Diffs:
Index: scribus/pdflib_core.cpp
===================================================================
--- scribus/pdflib_core.cpp	(revision 13763)
+++ scribus/pdflib_core.cpp	(revision 13764)
@@ -92,6 +92,7 @@
 	ActPageP(0),
 	Options(doc.PDF_Options),
 	Bvie(0),
+	ucs2Codec(0),
 	ObjCounter(7),
 	ResNam("RE"),
 	ResCount(0),
@@ -166,6 +167,12 @@
 	QMap<QString, QMap<uint, FPointArray> > usedFonts;
 	usedFonts.clear();
 	doc.getUsedFonts(usedFonts);
+	ucs2Codec = QTextCodec::codecForName("ISO-10646-UCS-2");
+	if (!ucs2Codec)
+	{
+		PDF_Error( tr("Qt build miss ISO-10646-UCS-2 text codec, pdf export is not possible") );
+		return false;
+	}
 	if (PDF_Begin_Doc(fn, PrefsManager::instance()->appPrefs.AvailFonts, usedFonts, doc.scMW()->bookmarkPalette->BView))
 	{
 		QMap<int, int> pageNsMpa;
@@ -340,8 +347,7 @@
 			tmp += '\\';
 		tmp += cc;
 	}
-	QTextCodec *codec = QTextCodec::codecForName("ISO-10646-UCS-2");
-	QByteArray cres = codec->fromUnicode( tmp );
+	QByteArray cres = ucs2Codec->fromUnicode( tmp );
 #ifndef WORDS_BIGENDIAN
 	// on little endian systems we ned to swap bytes:
 	uchar sw;
Index: scribus/pdflib_core.h
===================================================================
--- scribus/pdflib_core.h	(revision 13763)
+++ scribus/pdflib_core.h	(revision 13764)
@@ -15,9 +15,10 @@
 #include <string>
 #include <vector>
 
+class QImage;
+class QRect;
 class QString;
-class QRect;
-class QImage;
+class QTextCodec;
 class PageItem;
 class BookMItem;
 class BookMView;
@@ -251,6 +252,7 @@
 	QMap<QString,int> Transpar;
 	QMap<QString,ICCD> ICCProfiles;
 	QHash<QString, OCGInfo> OCGEntries;
+	QTextCodec* ucs2Codec;
 	int ObjCounter;
 	QString ResNam;
 	int ResCount;




More information about the scribus-commit mailing list