r19461 by jghali - 12572, patch 09/12: fix PDFOptionsIO::readSettings() error reporting

scribus-commit scribus-commit at lists.scribus.net
Sat Aug 30 00:59:18 UTC 2014


Author: jghali
Date: Sat Aug 30 00:59:18 2014
New Revision: 19461

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19461
Log:
12572, patch 09/12: fix PDFOptionsIO::readSettings() error reporting

Modified:
    trunk/Scribus/scribus/pdfoptionsio.cpp

Modified: trunk/Scribus/scribus/pdfoptionsio.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19461&path=/trunk/Scribus/scribus/pdfoptionsio.cpp
==============================================================================
--- trunk/Scribus/scribus/pdfoptionsio.cpp (original)
+++ trunk/Scribus/scribus/pdfoptionsio.cpp Sat Aug 30 00:59:18 2014
@@ -299,7 +299,7 @@
 	int errorLine, errorColumn;
 	if (!m_doc.setContent(&inDevice, &domError, &errorLine, &errorColumn))
 	{
-		m_error = QObject::tr("Unable to read settings XML:")
+		m_error = QObject::tr("Unable to read settings XML: %1")
 			.arg(QObject::tr("%1 (line %2 col %3)", "Load PDF settings")
 				.arg(domError).arg(errorLine).arg(errorColumn)
 			);
@@ -455,7 +455,7 @@
 	}
 	else
 	{
-		m_error = QObject::tr("Unable to read settings XML:")
+		m_error = QObject::tr("Unable to read settings XML: %1")
 			.arg(QObject::tr("<pdfVersion> invalid", "Load PDF settings"));
 		return false;
 	}
@@ -467,7 +467,7 @@
 	QDomNodeList nodes = parent.elementsByTagName(name);
 	if (nodes.count() != 1)
 	{
-		m_error = QObject::tr("Unable to read settings XML:")
+		m_error = QObject::tr("Unable to read settings XML: %1")
 			.arg(QObject::tr("found %1 <%2> nodes, need 1.", "Load PDF settings")
 				.arg(nodes.count()).arg(name)
 			);
@@ -482,15 +482,15 @@
 {
 	if (node.isNull())
 	{
-		m_error = QObject::tr("Unable to read settings XML:")
-			.arg(QObject::tr("unexpected null <%2> node", "Load PDF settings")
+		m_error = QObject::tr("Unable to read settings XML: %1")
+			.arg(QObject::tr("unexpected null <%1> node", "Load PDF settings")
 				.arg(name)
 			);
 		return QDomNode().toElement();
 	}
 	if (!node.isElement())
 	{
-		m_error = QObject::tr("Unable to read settings XML:")
+		m_error = QObject::tr("Unable to read settings XML: %1")
 			.arg(QObject::tr("node <%1> not an element", "Load PDF settings")
 				.arg(name)
 			);
@@ -499,7 +499,7 @@
 	QDomElement elem = node.toElement();
 	if (elem.tagName() != name)
 	{
-		m_error = QObject::tr("Unable to read settings XML:")
+		m_error = QObject::tr("Unable to read settings XML: %1")
 			.arg(QString("Internal error: element named <%1> not expected <%2>")
 					.arg(elem.tagName()).arg(name)
 			);
@@ -510,7 +510,7 @@
 		// We need to check that it has a `value' attribute
 		if (!elem.hasAttribute("value"))
 		{
-			m_error = QObject::tr("Unable to read settings XML:")
+			m_error = QObject::tr("Unable to read settings XML: %1")
 				.arg(QObject::tr("element <%1> lacks `value' attribute", "Load PDF settings")
 					.arg(name)
 				);
@@ -539,7 +539,7 @@
 	}
 	else
 	{
-		m_error = QObject::tr("Unable to read settings XML:")
+		m_error = QObject::tr("Unable to read settings XML: %1")
 			.arg(QObject::tr("element <%1> value must be `true' or `false'", "Load PDF settings")
 				.arg(name)
 			);
@@ -557,6 +557,14 @@
 	int result = elem.attribute("value").toInt(&ok);
 	if (ok)
 		(*value) = result;
+	else
+	{
+		m_error = QObject::tr("Unable to read settings XML: %1")
+			.arg(QObject::tr("element <%1> value must be an integer", "Load PDF settings")
+				.arg(name)
+			);
+		return false;
+	}
 	return ok;
 }
 
@@ -570,6 +578,14 @@
 	double result = ScCLocale::toDoubleC(elem.attribute("value"), &ok);
 	if (ok)
 		(*value) = result;
+	else
+	{
+		m_error = QObject::tr("Unable to read settings XML: %1")
+			.arg(QObject::tr("element <%1> value must be a double", "Load PDF settings")
+				.arg(name)
+			);
+		return false;
+	}
 	return ok;
 }
 
@@ -677,7 +693,7 @@
 		QString name (elem.attribute("name"));
 		if (name.isNull())
 		{
-			m_error = QObject::tr("Unable to read settings XML:")
+			m_error = QObject::tr("Unable to read settings XML: %1")
 				.arg(QObject::tr("element <lpiSettingsEntry> lacks `name' attribute", "Load PDF settings")
 					.arg(name)
 				);




More information about the scribus-commit mailing list