r23078 by jghali - Do not remove from cache fonts located in another local Scribus font folder (due to user having multiple versions installed for eg.)

scribus-commit scribus-commit at lists.scribus.net
Sun Jul 14 00:51:51 UTC 2019


Author: jghali
Date: Sun Jul 14 00:51:51 2019
New Revision: 23078

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23078
Log:
Do not remove from cache fonts located in another local Scribus font folder (due to user having multiple versions installed for eg.)

Modified:
    trunk/Scribus/scribus/scfonts.cpp

Modified: trunk/Scribus/scribus/scfonts.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23078&path=/trunk/Scribus/scribus/scfonts.cpp
==============================================================================
--- trunk/Scribus/scribus/scfonts.cpp	(original)
+++ trunk/Scribus/scribus/scfonts.cpp	Sun Jul 14 00:51:51 2019
@@ -1168,29 +1168,35 @@
 {
 	QDomDocument docu("fontcacherc");
 	QString st="<CachedFonts></CachedFonts>";
+
 	docu.setContent(st);
 	QDomElement elem = docu.documentElement();
-	QMap<QString, testCache>::Iterator it;
-	for (it = checkedFonts.begin(); it != checkedFonts.end(); ++it)
-	{
-		if (it.value().isChecked)
-		{
-			QDomElement fosu = docu.createElement("Font");
-			fosu.setAttribute("File", it.key());
-			fosu.setAttribute("Status", static_cast<int>(it.value().isOK));
-			fosu.setAttribute("Modified", it.value().lastMod.toString(Qt::ISODate));
-			elem.appendChild(fosu);
-		}
-	}
+	for (auto it = checkedFonts.cbegin(); it != checkedFonts.cend(); ++it)
+	{
+		const auto& checkedFont = it.value();
+
+		bool saveItem = checkedFont.isChecked;
+		if (!checkedFont.isChecked) // Font might be located in another local Scribus font folder
+			saveItem = QFile::exists(it.key());
+		if (!saveItem)
+			continue;
+
+		QDomElement fosu = docu.createElement("Font");
+		fosu.setAttribute("File", it.key());
+		fosu.setAttribute("Status", static_cast<int>(checkedFont.isOK));
+		fosu.setAttribute("Modified", checkedFont.lastMod.toString(Qt::ISODate));
+		elem.appendChild(fosu);
+	}
+
 	ScCore->setSplashStatus( QObject::tr("Writing updated Font Cache") );
-	QFile f(pf + "/checkfonts150.xml");
-	if (f.open(QIODevice::WriteOnly))
-	{
-		QTextStream s(&f);
-		s.setCodec("UTF-8");
-		s << docu.toString();
-		f.close();
-	}
+
+	QFile file(pf + "/checkfonts150.xml");
+	if (!file.open(QIODevice::WriteOnly))
+		return;
+	QTextStream s(&file);
+	s.setCodec("UTF-8");
+	s << docu.toString();
+	file.close();
 }
 
 void SCFonts::GetFonts(const QString& pf, bool showFontInfo)




More information about the scribus-commit mailing list