Skip to content

Commit

Permalink
Do not assume mScheme is not null
Browse files Browse the repository at this point in the history
Fixes crashes with ENABLE_MODELTEST set at build time on opening
options editor
  • Loading branch information
Sandro Santilli committed Dec 28, 2014
1 parent b96d943 commit 5acd35e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/gui/qgscolorschemelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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() )
Expand Down Expand Up @@ -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;
}
Expand All @@ -428,7 +428,7 @@ Qt::DropActions QgsColorSchemeModel::supportedDropActions() const

QStringList QgsColorSchemeModel::mimeTypes() const
{
if ( !mScheme->isEditable() )
if ( !mScheme || !mScheme->isEditable() )
{
return QStringList();
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 5acd35e

Please sign in to comment.