r16692 by jghali - #10072 : loop on file save caused by broken style hierarchy

scribus-commit scribus-commit at lists.scribus.net
Sat Jun 25 13:11:10 UTC 2011


Author: jghali
Date: Sat Jun 25 13:11:10 2011
New Revision: 16692

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16692
Log:
#10072 : loop on file save caused by broken style hierarchy

Modified:
    trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16692&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Sat Jun 25 13:11:10 2011
@@ -1225,6 +1225,11 @@
 		newStyle.setDefaultStyle(false);
 
 	readCharacterStyleAttrs(doc, attrs, newStyle);
+
+	// Check that a style is not its own parent
+	QString parentStyle = newStyle.parent();
+	if (parentStyle == newStyle.name())
+		newStyle.setParent(QString());
 }
 
 void Scribus134Format::readParagraphStyle(ScribusDoc *doc, ScXmlStreamReader& reader, ParagraphStyle& newStyle)
@@ -1241,8 +1246,9 @@
 		newStyle.setDefaultStyle(true);
 	else
 		newStyle.setDefaultStyle(false);
+
 	QString parentStyle = attrs.valueAsString("PARENT", "");
-	if (!parentStyle.isEmpty())
+	if (!parentStyle.isEmpty() && (parentStyle != newStyle.name()))
 	{
 		if (m_Doc->styleExists(parentStyle))
 			newStyle.setParent(parentStyle);

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16692&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Sat Jun 25 13:11:10 2011
@@ -2014,6 +2014,11 @@
 		newStyle.setDefaultStyle(false);
 
 	readCharacterStyleAttrs(doc, attrs, newStyle);
+
+	// Check that a style is not its own parent
+	QString parentStyle = newStyle.parent();
+	if (parentStyle == newStyle.name())
+		newStyle.setParent(QString());
 }
 
 void Scribus150Format::readParagraphStyle(ScribusDoc *doc, ScXmlStreamReader& reader, ParagraphStyle& newStyle)
@@ -2032,7 +2037,7 @@
 		newStyle.setDefaultStyle(false);
 	
 	QString parentStyle = attrs.valueAsString("PARENT", "");
-	if (!parentStyle.isEmpty())
+	if (!parentStyle.isEmpty() && (parentStyle != newStyle.name()))
 	{
 		if (m_Doc->styleExists(parentStyle))
 			newStyle.setParent(parentStyle);

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16692&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sat Jun 25 13:11:10 2011
@@ -1028,29 +1028,24 @@
 		{
 			if (!retList.contains(ff))
 				retList.append(ff);
-		}
-		else
-		{
-			QList<int> retList2;
-			QString par = docParagraphStyles[ff].parent();
-			retList2.prepend(ff);
-			while (!par.isEmpty())
-			{
-				for (int pp = 0; pp < docParagraphStyles.count(); ++pp)
-				{
-					if (docParagraphStyles[pp].name() == par)
-					{
-						if (!retList2.contains(pp))
-							retList2.prepend(pp);
-						par = docParagraphStyles[pp].parent();
-					}
-				}
-			}
-			for (int r = 0; r < retList2.count(); ++r)
-			{
-				if (!retList.contains(retList2[r]))
-					retList.append(retList2[r]);
-			}
+			continue;
+		}
+
+		QList<int> retList2;
+		QString name = docParagraphStyles[ff].name();
+		QString par  = docParagraphStyles[ff].parent();
+		retList2.prepend(ff);
+		while ((!par.isEmpty()) && (par != name))
+		{
+			int pp = docParagraphStyles.find(par);
+			if ((pp >= 0) && (!retList2.contains(pp)))
+				retList2.prepend(pp);
+			par = (pp >= 0) ? docParagraphStyles[pp].parent() : QString();
+		}
+		for (int r = 0; r < retList2.count(); ++r)
+		{
+			if (!retList.contains(retList2[r]))
+				retList.append(retList2[r]);
 		}
 	}
 	return retList;
@@ -1065,29 +1060,24 @@
 		{
 			if (!retList.contains(ff))
 				retList.append(ff);
-		}
-		else
-		{
-			QList<int> retList2;
-			QString par = docCharStyles[ff].parent();
-			retList2.prepend(ff);
-			while (!par.isEmpty())
-			{
-				for (int pp = 0; pp < docCharStyles.count(); ++pp)
-				{
-					if (docCharStyles[pp].name() == par)
-					{
-						if (!retList2.contains(pp))
-							retList2.prepend(pp);
-						par = docCharStyles[pp].parent();
-					}
-				}
-			}
-			for (int r = 0; r < retList2.count(); ++r)
-			{
-				if (!retList.contains(retList2[r]))
-					retList.append(retList2[r]);
-			}
+			continue;
+		}
+
+		QList<int> retList2;
+		QString name = docCharStyles[ff].name();
+		QString par  = docCharStyles[ff].parent();
+		retList2.prepend(ff);
+		while ((!par.isEmpty()) && (par != name))
+		{
+			int pp = docCharStyles.find(par);
+			if ((pp >= 0) && (!retList2.contains(pp)))
+				retList2.prepend(pp);
+			par = (pp >= 0) ? docCharStyles[pp].parent() : QString();
+		}
+		for (int r = 0; r < retList2.count(); ++r)
+		{
+			if (!retList.contains(retList2[r]))
+				retList.append(retList2[r]);
 		}
 	}
 	return retList;




More information about the scribus-commit mailing list