r22303 by craig -

scribus-commit scribus-commit at lists.scribus.net
Fri Dec 29 22:59:25 UTC 2017


Author: craig
Date: Fri Dec 29 22:59:25 2017
New Revision: 22303

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22303
Log:
Fix Coverity 1350070

Modified:
    trunk/Scribus/scribus/nfttemplate.cpp

Modified: trunk/Scribus/scribus/nfttemplate.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22303&path=/trunk/Scribus/scribus/nfttemplate.cpp
==============================================================================
--- trunk/Scribus/scribus/nfttemplate.cpp	(original)
+++ trunk/Scribus/scribus/nfttemplate.cpp	Fri Dec 29 22:59:25 2017
@@ -24,58 +24,62 @@
 	if (!tmplXml.exists())
 		return;
 
-	QString newTmplXml = "";
-	QString tmp;
-	bool collect = false;
-	tmplXml.open(QIODevice::ReadOnly);
-	QTextStream stream(&tmplXml);
-	stream.setCodec("UTF-8");
-	QString line = stream.readLine();
-	while (!line.isNull())
+	if (tmplXml.open(QIODevice::ReadOnly))
 	{
-		if ((line.indexOf(enCategory) != -1) || collect)
+		QString newTmplXml;
+		QString tmp;
+		bool collect = false;
+		QTextStream stream(&tmplXml);
+		stream.setCodec("UTF-8");
+		QString line = stream.readLine();
+		while (!line.isNull())
 		{
-			collect = true;
-			line += "\n";
-			tmp += line;
-			if (line.indexOf("name") != -1)
+			if ((line.indexOf(enCategory) != -1) || collect)
 			{
-				if (line.indexOf(name) == -1)
+				collect = true;
+				line += "\n";
+				tmp += line;
+				if (line.indexOf("name") != -1)
+				{
+					if (line.indexOf(name) == -1)
+					{
+						collect = false;
+						newTmplXml += tmp;
+						tmp = "";
+					}
+				}
+				else if (line.indexOf("file") != -1)
+				{
+					QString shortFile = file.right(file.length() - file.lastIndexOf("/") -1);
+					if (line.indexOf(shortFile) == -1)
+					{
+						collect = false;
+						newTmplXml += tmp;
+						tmp = "";
+					}
+				}
+				else if (line.indexOf("</template>") != -1)
 				{
 					collect = false;
-					newTmplXml += tmp;
 					tmp = "";
 				}
-			} 
-			else if (line.indexOf("file") != -1)
+			}
+			else
 			{
-				QString shortFile = file.right(file.length() - file.lastIndexOf("/") -1);
-				if (line.indexOf(shortFile) == -1)
-				{
-					collect = false;
-					newTmplXml += tmp;
-					tmp = "";
-				}
-			} 
-			else if (line.indexOf("</template>") != -1)
-			{
-				collect = false;
-				tmp = "";
+				line += "\n";
+				newTmplXml += line;
 			}
+			line = stream.readLine();
 		}
-		else
+		tmplXml.close();
+		if (tmplXml.open(QIODevice::WriteOnly))
 		{
-			line += "\n";
-			newTmplXml += line;
+			QTextStream instream(&tmplXml);
+			instream.setCodec("UTF-8");
+			instream << newTmplXml;
+			tmplXml.close();
 		}
-		line = stream.readLine();
 	}
-	tmplXml.close();
-	tmplXml.open(QIODevice::WriteOnly);
-	QTextStream instream(&tmplXml);
-	instream.setCodec("UTF-8");
-	instream << newTmplXml;
-	tmplXml.close();
 }
 
 bool nfttemplate::canWrite()




More information about the scribus-commit mailing list