Skip to content
Permalink
Browse files

Do not assume mScheme is not null

Fixes crashes with ENABLE_MODELTEST set at build time on opening
options editor
  • Loading branch information
Sandro Santilli
Sandro Santilli committed Dec 28, 2014
1 parent b96d943 commit 5acd35e9289d4611f2c5404ab24a6e671e3568fe
Showing with 8 additions and 8 deletions.
  1. +8 −8 src/gui/qgscolorschemelist.cpp
@@ -339,7 +339,7 @@ Qt::ItemFlags QgsColorSchemeModel::flags( const QModelIndex &index ) const
{
case ColorSwatch:
case ColorLabel:
if ( mScheme->isEditable() )
if ( mScheme && mScheme->isEditable() )
{
flags = flags | Qt::ItemIsEditable;
}
@@ -353,7 +353,7 @@ bool QgsColorSchemeModel::setData( const QModelIndex &index, const QVariant &val
{
Q_UNUSED( role );

if ( !mScheme->isEditable() )
if ( !mScheme || !mScheme->isEditable() )
return false;

if ( !index.isValid() )
@@ -416,7 +416,7 @@ QVariant QgsColorSchemeModel::headerData( int section, Qt::Orientation orientati

Qt::DropActions QgsColorSchemeModel::supportedDropActions() const
{
if ( mScheme->isEditable() )
if ( mScheme && mScheme->isEditable() )
{
return Qt::CopyAction | Qt::MoveAction;
}
@@ -428,7 +428,7 @@ Qt::DropActions QgsColorSchemeModel::supportedDropActions() const

QStringList QgsColorSchemeModel::mimeTypes() const
{
if ( !mScheme->isEditable() )
if ( !mScheme || !mScheme->isEditable() )
{
return QStringList();
}
@@ -462,7 +462,7 @@ bool QgsColorSchemeModel::dropMimeData( const QMimeData *data, Qt::DropAction ac
{
Q_UNUSED( column );

if ( !mScheme->isEditable() )
if ( !mScheme || !mScheme->isEditable() )
{
return false;
}
@@ -537,7 +537,7 @@ void QgsColorSchemeModel::setScheme( QgsColorScheme *scheme, const QString &cont

bool QgsColorSchemeModel::removeRows( int row, int count, const QModelIndex &parent )
{
if ( !mScheme->isEditable() )
if ( !mScheme || !mScheme->isEditable() )
{
return false;
}
@@ -567,7 +567,7 @@ bool QgsColorSchemeModel::insertRows( int row, int count, const QModelIndex& par
{
Q_UNUSED( parent );

if ( !mScheme->isEditable() )
if ( !mScheme || !mScheme->isEditable() )
{
return false;
}
@@ -585,7 +585,7 @@ bool QgsColorSchemeModel::insertRows( int row, int count, const QModelIndex& par

void QgsColorSchemeModel::addColor( const QColor &color, const QString &label )
{
if ( !mScheme->isEditable() )
if ( !mScheme || !mScheme->isEditable() )
{
return;
}

0 comments on commit 5acd35e

Please sign in to comment.
You can’t perform that action at this time.