r20927 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Sun Feb 7 00:30:33 UTC 2016


Author: jghali
Date: Sun Feb  7 00:30:33 2016
New Revision: 20927

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20927
Log:
coverity #1350740: uninitialized pointer field

Modified:
    trunk/Scribus/scribus/plugins/picbrowser/multicombobox.cpp
    trunk/Scribus/scribus/plugins/picbrowser/multicombobox.h

Modified: trunk/Scribus/scribus/plugins/picbrowser/multicombobox.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20927&path=/trunk/Scribus/scribus/plugins/picbrowser/multicombobox.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/picbrowser/multicombobox.cpp	(original)
+++ trunk/Scribus/scribus/plugins/picbrowser/multicombobox.cpp	Sun Feb  7 00:30:33 2016
@@ -8,161 +8,162 @@
 
 #include <QKeyEvent>
 #include <QObject>
-#include <QWidget>
-
-
-multiComboboxModel::multiComboboxModel ( QObject* parent ) : QStandardItemModel ( parent )
-{
-	insertColumn ( 0 );
-}
-
-Qt::ItemFlags multiComboboxModel::flags ( const QModelIndex& index ) const
-{
-	return QStandardItemModel::flags ( index ) | Qt::ItemIsUserCheckable;
-}
-
-
-multiView::multiView ( QWidget* parent ) : QListView ( parent )
-{
-}
-
-
-multiView::multiView ( multiCombobox* parent ) : QListView ( parent )
-{
-	parentMcb = parent;
-}
-
-
-bool multiView::eventFilter ( QObject* object, QEvent* event )
-{
-	if ( event->type() == QEvent::MouseButtonRelease )
-	{
-		QMouseEvent* mouse = static_cast<QMouseEvent*> ( event );
-		QModelIndex index = indexAt ( mouse->pos() );
-
-		if ( index.isValid() )
-		{
-			QModelIndexList selectedList = selectedIndexes();
-
-			for ( int i = 0 ; i < selectedList.size() ; ++i )
-			{
-				parentMcb->switchCheckstate ( selectedList.at ( i ).row() );
-			}
-			return true;
-		}
-	}
-	else if ( event->type() == QEvent::KeyPress )
-	{
-		QKeyEvent* key = static_cast<QKeyEvent*> ( event );
-
-		if ( ( key->key() == Qt::Key_Return ) || ( key->key() == Qt::Key_Enter ) )
-		{
-			QModelIndexList selectedList = selectedIndexes();
-
-			for ( int i = 0 ; i < selectedList.size() ; ++i )
-			{
-				parentMcb->switchCheckstate ( selectedList.at ( i ).row() );
-			}
-
-			return true;
-		}
-	}
-
-	return false;
-}
-
-
-
-multiCombobox::multiCombobox ( QWidget *parent ) : QComboBox ( parent )
-{
-	mcbModel = new multiComboboxModel ( this );
-	mcbView = new multiView ( this );
-
-	setModel ( mcbModel );
-	setView ( mcbView );
-
-	mcbView->installEventFilter ( mcbView );
-	mcbView->viewport()->installEventFilter ( mcbView );
-
-//setEditable(true);
-//lineEdit()->setReadOnly(true);
-//lineEdit()->setEnabled(false);
-	view()->setSelectionMode ( QAbstractItemView::ExtendedSelection );
-}
-
-
-void multiCombobox::setCheckstate ( int index, int checked )
-{
-	int itemsCount = count();
-
-	if ( index < 0 || index >= itemsCount )
-	{
-		return;
-	}
-
-	if ( checked == 1 )
-	{
-		QComboBox::setItemData ( index, Qt::Checked, Qt::CheckStateRole );
-	}
-	else if ( checked == 2 )
-	{
-		QComboBox::setItemData ( index, Qt::PartiallyChecked, Qt::CheckStateRole );
-	}
-	else
-	{
-		QComboBox::setItemData ( index, Qt::Unchecked, Qt::CheckStateRole );
-	}
-}
-
-
-int multiCombobox::checkstate ( int index )
-{
-	int itemsCount = count();
-
-	if ( index < 0 || index >= itemsCount )
-	{
-		return false;
-	}
-
-	QVariant var = QComboBox::itemData ( index, Qt::CheckStateRole );
-
-	if ( var == Qt::Checked )
-	{
-		return 1;
-	}
-	else if ( var == Qt::PartiallyChecked )
-	{
-		return 2;
-	}
-	else
-	{
-		return 0;
-	}
-}
-
-
-void multiCombobox::switchCheckstate ( int row )
-{
-	if ( checkstate ( row ) )
-	{
-		setCheckstate ( row, 0 );
-	}
-	else
-	{
-		setCheckstate ( row, 1 );
-	}
-
-	emit checkstateChanged ( row );
-}
-
-
-int multiCombobox::addItem ( QString text, int checked )
-{
-	QComboBox::addItem ( text );
-
-	int itemsCount = count();
-
-	setCheckstate ( itemsCount-1, checked );
-
-	return itemsCount-1;
-}
+#include <QWidget>
+
+
+multiComboboxModel::multiComboboxModel ( QObject* parent ) : QStandardItemModel ( parent )
+{
+	insertColumn ( 0 );
+}
+
+Qt::ItemFlags multiComboboxModel::flags ( const QModelIndex& index ) const
+{
+	return QStandardItemModel::flags ( index ) | Qt::ItemIsUserCheckable;
+}
+
+
+multiView::multiView ( QWidget* parent ) : QListView ( parent )
+{
+	parentMcb = 0;
+}
+
+
+multiView::multiView ( multiCombobox* parent ) : QListView ( parent )
+{
+	parentMcb = parent;
+}
+
+
+bool multiView::eventFilter ( QObject* object, QEvent* event )
+{
+	if ( event->type() == QEvent::MouseButtonRelease )
+	{
+		QMouseEvent* mouse = static_cast<QMouseEvent*> ( event );
+		QModelIndex index = indexAt ( mouse->pos() );
+
+		if ( index.isValid() )
+		{
+			QModelIndexList selectedList = selectedIndexes();
+
+			for ( int i = 0 ; i < selectedList.size() ; ++i )
+			{
+				parentMcb->switchCheckstate ( selectedList.at ( i ).row() );
+			}
+			return true;
+		}
+	}
+	else if ( event->type() == QEvent::KeyPress )
+	{
+		QKeyEvent* key = static_cast<QKeyEvent*> ( event );
+
+		if ( ( key->key() == Qt::Key_Return ) || ( key->key() == Qt::Key_Enter ) )
+		{
+			QModelIndexList selectedList = selectedIndexes();
+
+			for ( int i = 0 ; i < selectedList.size() ; ++i )
+			{
+				parentMcb->switchCheckstate ( selectedList.at ( i ).row() );
+			}
+
+			return true;
+		}
+	}
+
+	return false;
+}
+
+
+
+multiCombobox::multiCombobox ( QWidget *parent ) : QComboBox ( parent )
+{
+	mcbModel = new multiComboboxModel ( this );
+	mcbView = new multiView ( this );
+
+	setModel ( mcbModel );
+	setView ( mcbView );
+
+	mcbView->installEventFilter ( mcbView );
+	mcbView->viewport()->installEventFilter ( mcbView );
+
+//setEditable(true);
+//lineEdit()->setReadOnly(true);
+//lineEdit()->setEnabled(false);
+	view()->setSelectionMode ( QAbstractItemView::ExtendedSelection );
+}
+
+
+void multiCombobox::setCheckstate ( int index, int checked )
+{
+	int itemsCount = count();
+
+	if ( index < 0 || index >= itemsCount )
+	{
+		return;
+	}
+
+	if ( checked == 1 )
+	{
+		QComboBox::setItemData ( index, Qt::Checked, Qt::CheckStateRole );
+	}
+	else if ( checked == 2 )
+	{
+		QComboBox::setItemData ( index, Qt::PartiallyChecked, Qt::CheckStateRole );
+	}
+	else
+	{
+		QComboBox::setItemData ( index, Qt::Unchecked, Qt::CheckStateRole );
+	}
+}
+
+
+int multiCombobox::checkstate ( int index )
+{
+	int itemsCount = count();
+
+	if ( index < 0 || index >= itemsCount )
+	{
+		return false;
+	}
+
+	QVariant var = QComboBox::itemData ( index, Qt::CheckStateRole );
+
+	if ( var == Qt::Checked )
+	{
+		return 1;
+	}
+	else if ( var == Qt::PartiallyChecked )
+	{
+		return 2;
+	}
+	else
+	{
+		return 0;
+	}
+}
+
+
+void multiCombobox::switchCheckstate ( int row )
+{
+	if ( checkstate ( row ) )
+	{
+		setCheckstate ( row, 0 );
+	}
+	else
+	{
+		setCheckstate ( row, 1 );
+	}
+
+	emit checkstateChanged ( row );
+}
+
+
+int multiCombobox::addItem ( QString text, int checked )
+{
+	QComboBox::addItem ( text );
+
+	int itemsCount = count();
+
+	setCheckstate ( itemsCount-1, checked );
+
+	return itemsCount-1;
+}

Modified: trunk/Scribus/scribus/plugins/picbrowser/multicombobox.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20927&path=/trunk/Scribus/scribus/plugins/picbrowser/multicombobox.h
==============================================================================
--- trunk/Scribus/scribus/plugins/picbrowser/multicombobox.h	(original)
+++ trunk/Scribus/scribus/plugins/picbrowser/multicombobox.h	Sun Feb  7 00:30:33 2016
@@ -12,45 +12,45 @@
 class QObject;
 class QModelIndex;
 class QWidget;
-class multiCombobox;
-
-class multiComboboxModel : public QStandardItemModel
-{
-	public:
-		multiComboboxModel ( QObject* parent = 0 );
-		Qt::ItemFlags flags ( const QModelIndex& index ) const;
-};
-
-
-class multiView : public QListView
-{
-	public:
-		multiView ( QWidget* parent = 0 );
-		multiView ( multiCombobox* parent );
-		bool eventFilter ( QObject* object, QEvent* event );
-
-	private:
-		multiCombobox *parentMcb;
-};
-
-
-class multiCombobox : public QComboBox
-{
-		Q_OBJECT
-
-	public:
-		multiCombobox ( QWidget *parent = 0 );
-
-		void setCheckstate ( int index, int checked );
-		int checkstate ( int index );
-		void switchCheckstate ( int row );
-
-		int addItem ( QString text, int checked=0 );
-
-	private:
-		multiComboboxModel *mcbModel;
-		multiView *mcbView;
-
-	signals:
-		void checkstateChanged ( int );
-};
+class multiCombobox;
+
+class multiComboboxModel : public QStandardItemModel
+{
+	public:
+		multiComboboxModel ( QObject* parent = 0 );
+		Qt::ItemFlags flags ( const QModelIndex& index ) const;
+};
+
+
+class multiView : public QListView
+{
+	public:
+		multiView ( QWidget* parent = 0 );
+		multiView ( multiCombobox* parent );
+		bool eventFilter ( QObject* object, QEvent* event );
+
+	private:
+		multiCombobox *parentMcb;
+};
+
+
+class multiCombobox : public QComboBox
+{
+		Q_OBJECT
+
+	public:
+		multiCombobox ( QWidget *parent = 0 );
+
+		void setCheckstate ( int index, int checked );
+		int checkstate ( int index );
+		void switchCheckstate ( int row );
+
+		int addItem ( QString text, int checked=0 );
+
+	private:
+		multiComboboxModel *mcbModel;
+		multiView *mcbView;
+
+	signals:
+		void checkstateChanged ( int );
+};




More information about the scribus-commit mailing list