r17726 by jghali - #10909: Crash in color palette

scribus-commit scribus-commit at lists.scribus.net
Sat Jul 21 10:17:44 UTC 2012


Author: jghali
Date: Sat Jul 21 10:17:44 2012
New Revision: 17726

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17726
Log:
#10909: Crash in color palette

Modified:
    trunk/Scribus/scribus/ui/swatchcombo.cpp

Modified: trunk/Scribus/scribus/ui/swatchcombo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17726&path=/trunk/Scribus/scribus/ui/swatchcombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/swatchcombo.cpp (original)
+++ trunk/Scribus/scribus/ui/swatchcombo.cpp Sat Jul 21 10:17:44 2012
@@ -84,6 +84,7 @@
 	QFontMetrics fm(font());
 	setToolTip(text);
 	QList<QTreeWidgetItem*> lg;
+
 	if (text == "Scribus Small")
 	{
 		QString elText = fm.elidedText(text, Qt::ElideMiddle, width());
@@ -92,26 +93,26 @@
 		dataTree->setCurrentItem(lg[0]);
 		return;
 	}
-	else
+
+	QFileInfo fo(text);
+	QString txt = fo.baseName();
+	lg = dataTree->findItems(txt, Qt::MatchExactly | Qt::MatchRecursive);
+	if (lg.count() <= 0) return;
+
+	QString dText = fo.absolutePath();
+	for (int a = 0; a < lg.count(); a++)
 	{
-		QFileInfo fo(text);
-		QString txt = fo.baseName();
-		QString elText = fm.elidedText(txt, Qt::ElideMiddle, width());
-		setText(elText);
-		QString dText = fo.absolutePath();
-		lg = dataTree->findItems(txt, Qt::MatchExactly | Qt::MatchRecursive);
-		if (lg.count() > 0)
+		if (dText == lg[a]->data(0, Qt::UserRole).toString())
 		{
-			for (int a = 0; a < lg.count(); a++)
-			{
-				if (dText == lg[a]->data(0, Qt::UserRole).toString())
-				{
-					dataTree->setCurrentItem(lg[0]);
-					break;
-				}
-			}
+			dataTree->setCurrentItem(lg[0]);
+			QString elText = fm.elidedText(txt, Qt::ElideMiddle, width());
+			setText(elText);
+			break;
 		}
 	}
+
+	if(!dataTree->currentItem())
+		setCurrentComboItem("Scribus Small");
 }
 
 QTreeWidgetItem* SwatchCombo::currentItem()




More information about the scribus-commit mailing list