r20880 by craig -

scribus-commit scribus-commit at lists.scribus.net
Tue Feb 2 21:05:02 UTC 2016


Author: craig
Date: Tue Feb  2 21:05:02 2016
New Revision: 20880

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20880
Log:
coverity #93094: fix unchecked dynamic_cast and remove some unnecessary code

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

Modified: trunk/Scribus/scribus/ui/spalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20880&path=/trunk/Scribus/scribus/ui/spalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/spalette.cpp	(original)
+++ trunk/Scribus/scribus/ui/spalette.cpp	Tue Feb  2 21:05:02 2016
@@ -55,12 +55,118 @@
 	if (currentDoc != NULL)
 	{
 		QStringList st;
-		st.clear();
 		addItem( tr("No Style"));
 		for (int x = 0; x < currentDoc->paragraphStyles().count(); ++x)
 		{
 			if ( !currentDoc->paragraphStyles()[x].name().isEmpty() )
 				st.append(currentDoc->paragraphStyles()[x].name());
+		}
+		st.sort();
+		addItems(st);
+	}
+	QListView *tmpView = dynamic_cast<QListView*>(view());
+	if (tmpView)
+	{
+		int tmpWidth = tmpView->sizeHintForColumn(0);
+		if (tmpWidth > 0)
+			tmpView->setMinimumWidth(tmpWidth + 24);
+	}
+	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+}
+
+void ParaStyleComboBox::selFormat(int e)
+{
+	if (e == 0)
+		emit newStyle(QString::null);
+	else
+		emit newStyle(currentText());
+}
+
+CharStyleComboBox::CharStyleComboBox(QWidget* parent) : QComboBox(parent)
+{
+	setEditable(false);
+	addItem( tr("No Style"));
+	currentDoc = NULL;
+	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+}
+
+void CharStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
+{
+	currentDoc = newCurrentDoc;
+	updateFormatList();
+}
+
+void CharStyleComboBox::setFormat(QString name)
+{
+	setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
+}
+
+void CharStyleComboBox::updateFormatList()
+{
+	disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+	clear();
+	if (currentDoc != NULL)
+	{
+		QStringList st;
+		addItem( tr("No Style"));
+		for (int x = 0; x < currentDoc->charStyles().count(); ++x)
+		{
+			if ( !currentDoc->charStyles()[x].name().isEmpty() )
+				st.append(currentDoc->charStyles()[x].name());
+		}
+		st.sort();
+		addItems(st);
+	}
+	QListView *tmpView = dynamic_cast<QListView*>(view());
+	if (tmpView)
+	{
+		int tmpWidth = tmpView->sizeHintForColumn(0);
+		if (tmpWidth > 0)
+			tmpView->setMinimumWidth(tmpWidth + 24);
+	}
+	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+}
+
+void CharStyleComboBox::selFormat(int e)
+{
+	if (e == 0)
+		emit newStyle(QString::null);
+	else
+		emit newStyle(currentText());
+}
+
+CellStyleComboBox::CellStyleComboBox(QWidget* parent) : QComboBox(parent)
+{
+	setEditable(false);
+	addItem( tr("No Style"));
+	currentDoc = NULL;
+	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+}
+
+void CellStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
+{
+	currentDoc = newCurrentDoc;
+	updateFormatList();
+}
+
+void CellStyleComboBox::setFormat(QString name)
+{
+	setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
+}
+
+void CellStyleComboBox::updateFormatList()
+{
+	disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+	clear();
+	if (currentDoc != NULL)
+	{
+		QStringList st;
+		st.clear();
+		addItem( tr("No Style"));
+		for (int x = 0; x < currentDoc->cellStyles().count(); ++x)
+		{
+			if ( !currentDoc->cellStyles()[x].name().isEmpty() )
+				st.append(currentDoc->cellStyles()[x].name());
 		}
 		st.sort();
 		addItems(st);
@@ -72,91 +178,38 @@
 	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
 }
 
-void ParaStyleComboBox::selFormat(int e)
-{
-	if (e == 0)
-	{
-		emit newStyle(QString::null);
-	}
-	else
-	{
-		emit newStyle(currentText());
-	}
-}
-
-CharStyleComboBox::CharStyleComboBox(QWidget* parent) : QComboBox(parent)
-{
-	setEditable(false);
-	addItem( tr("No Style"));
-	currentDoc = NULL;
-	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-}
-
-void CharStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
-{
-	currentDoc = newCurrentDoc;
-	updateFormatList();
-}
-
-void CharStyleComboBox::setFormat(QString name)
-{
-	setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
-}
-
-void CharStyleComboBox::updateFormatList()
-{
-	disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-	clear();
-	if (currentDoc != NULL)
-	{
-		QStringList st;
-		addItem( tr("No Style"));
-		for (int x = 0; x < currentDoc->charStyles().count(); ++x)
-		{
-			if ( !currentDoc->charStyles()[x].name().isEmpty() )
-				st.append(currentDoc->charStyles()[x].name());
-		}
-		st.sort();
-		addItems(st);
-	}
-	QListView *tmpView = dynamic_cast<QListView*>(view());
-	if (tmpView)
-	{
-		int tmpWidth = tmpView->sizeHintForColumn(0);
-		if (tmpWidth > 0)
-			tmpView->setMinimumWidth(tmpWidth + 24);
-	}
-	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-}
-
-void CharStyleComboBox::selFormat(int e)
-{
-	if (e == 0)
-		emit newStyle(QString::null);
-	else
-		emit newStyle(currentText());
-}
-
-CellStyleComboBox::CellStyleComboBox(QWidget* parent) : QComboBox(parent)
-{
-	setEditable(false);
-	addItem( tr("No Style"));
-	currentDoc = NULL;
-	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-}
-
-void CellStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
-{
-	currentDoc = newCurrentDoc;
-	updateFormatList();
-}
-
-void CellStyleComboBox::setFormat(QString name)
-{
-	setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
-}
-
-void CellStyleComboBox::updateFormatList()
+void CellStyleComboBox::selFormat(int e)
+{
+	if (e == 0)
+	{
+		emit newStyle(QString::null);
+	}
+	else
+	{
+		emit newStyle(currentText());
+	}
+}
+
+TableStyleComboBox::TableStyleComboBox(QWidget* parent) : QComboBox(parent)
+{
+	setEditable(false);
+	addItem( tr("No Style"));
+	currentDoc = NULL;
+	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+}
+
+void TableStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
+{
+	currentDoc = newCurrentDoc;
+	updateFormatList();
+}
+
+void TableStyleComboBox::setFormat(QString name)
+{
+	setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
+}
+
+void TableStyleComboBox::updateFormatList()
 {
 	disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
 	clear();
@@ -165,10 +218,10 @@
 		QStringList st;
 		st.clear();
 		addItem( tr("No Style"));
-		for (int x = 0; x < currentDoc->cellStyles().count(); ++x)
-		{
-			if ( !currentDoc->cellStyles()[x].name().isEmpty() )
-				st.append(currentDoc->cellStyles()[x].name());
+		for (int x = 0; x < currentDoc->tableStyles().count(); ++x)
+		{
+			if ( !currentDoc->tableStyles()[x].name().isEmpty() )
+				st.append(currentDoc->tableStyles()[x].name());
 		}
 		st.sort();
 		addItems(st);
@@ -180,61 +233,6 @@
 	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
 }
 
-void CellStyleComboBox::selFormat(int e)
-{
-	if (e == 0)
-	{
-		emit newStyle(QString::null);
-	}
-	else
-	{
-		emit newStyle(currentText());
-	}
-}
-
-TableStyleComboBox::TableStyleComboBox(QWidget* parent) : QComboBox(parent)
-{
-	setEditable(false);
-	addItem( tr("No Style"));
-	currentDoc = NULL;
-	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-}
-
-void TableStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
-{
-	currentDoc = newCurrentDoc;
-	updateFormatList();
-}
-
-void TableStyleComboBox::setFormat(QString name)
-{
-	setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
-}
-
-void TableStyleComboBox::updateFormatList()
-{
-	disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-	clear();
-	if (currentDoc != NULL)
-	{
-		QStringList st;
-		st.clear();
-		addItem( tr("No Style"));
-		for (int x = 0; x < currentDoc->tableStyles().count(); ++x)
-		{
-			if ( !currentDoc->tableStyles()[x].name().isEmpty() )
-				st.append(currentDoc->tableStyles()[x].name());
-		}
-		st.sort();
-		addItems(st);
-	}
-	QListView *tmpView = dynamic_cast<QListView*>(view());
-	int tmpWidth = tmpView->sizeHintForColumn(0);
-	if (tmpWidth > 0)
-		tmpView->setMinimumWidth(tmpWidth + 24);
-	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-}
-
 void TableStyleComboBox::selFormat(int e)
 {
 	if (e == 0)




More information about the scribus-commit mailing list