r17713 by jghali - fix sometime incorrect caching of color profiles

scribus-commit scribus-commit at lists.scribus.net
Fri Jul 13 10:59:51 UTC 2012


Author: jghali
Date: Fri Jul 13 10:59:50 2012
New Revision: 17713

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17713
Log:
fix sometime incorrect caching of color profiles

Modified:
    trunk/Scribus/scribus/colormgmt/sccolorprofilecache.cpp

Modified: trunk/Scribus/scribus/colormgmt/sccolorprofilecache.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17713&path=/trunk/Scribus/scribus/colormgmt/sccolorprofilecache.cpp
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sccolorprofilecache.cpp (original)
+++ trunk/Scribus/scribus/colormgmt/sccolorprofilecache.cpp Fri Jul 13 10:59:50 2012
@@ -9,11 +9,17 @@
 void ScColorProfileCache::addProfile(const ScColorProfile& profile)
 {
 	QString path = profile.profilePath();
-	if (!path.isEmpty())
+	if (path.isEmpty())
+		return;
+
+	QMap<QString, QWeakPointer<ScColorProfileData> >::iterator iter = m_profileMap.find(path);
+	if (iter != m_profileMap.end())
 	{
-		if (!m_profileMap.contains(path))
-			m_profileMap.insert(path, profile.weakRef());
+		QSharedPointer<ScColorProfileData> strongRef = iter.value().toStrongRef();
+		if (strongRef) return;
 	}
+
+	m_profileMap.insert(path, profile.weakRef());
 }
 
 void ScColorProfileCache::removeProfile(const QString& profilePath)
@@ -28,7 +34,13 @@
 	
 bool ScColorProfileCache::contains(const QString& profilePath)
 {
-	return m_profileMap.contains(profilePath);
+	QMap<QString, QWeakPointer<ScColorProfileData> >::iterator iter = m_profileMap.find(profilePath);
+	if (iter != m_profileMap.end())
+	{
+		QSharedPointer<ScColorProfileData> strongRef = iter.value().toStrongRef();
+		return (!strongRef.isNull());
+	}
+	return false;
 }
 
 ScColorProfile ScColorProfileCache::profile(const QString& profilePath)




More information about the scribus-commit mailing list