Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #2318 from slarosa/fix_crash_export_ramp
Browse files Browse the repository at this point in the history
[stylemanager dialog] fix crash when exporting to PNG/SVG color ramp
  • Loading branch information
NathanW2 committed Sep 16, 2015
2 parents 4897cdf + 7a41a2d commit 29fc46a
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Expand Up @@ -185,11 +185,14 @@ void QgsStyleV2ManagerDialog::on_tabItemType_currentChanged( int )
// when in Color Ramp tab, add menu to add item button // when in Color Ramp tab, add menu to add item button
if ( currentItemType() == 3 ) if ( currentItemType() == 3 )
{ {
btnShare->menu()->actions().at( 0 )->setVisible( false );
btnShare->menu()->actions().at( 1 )->setVisible( false );

QStringList rampTypes; QStringList rampTypes;
rampTypes << tr( "Gradient" ) << tr( "Random" ) << tr( "ColorBrewer" ); rampTypes << tr( "Gradient" ) << tr( "Random" ) << tr( "ColorBrewer" );
rampTypes << tr( "cpt-city" ); // todo, only for rasters? rampTypes << tr( "cpt-city" ); // todo, only for rasters?
QMenu* menu = new QMenu( btnAddItem ); QMenu* menu = new QMenu( btnAddItem );
Q_FOREACH ( const QString& rampType, rampTypes ) Q_FOREACH( const QString& rampType, rampTypes )
{ {
menu->addAction( rampType ); menu->addAction( rampType );
} }
Expand All @@ -199,6 +202,9 @@ void QgsStyleV2ManagerDialog::on_tabItemType_currentChanged( int )
} }
else else
{ {
btnShare->menu()->actions().at( 0 )->setVisible( true );
btnShare->menu()->actions().at( 1 )->setVisible( true );

if ( btnAddItem->menu() ) if ( btnAddItem->menu() )
{ {
disconnect( btnAddItem->menu(), SIGNAL( triggered( QAction* ) ), disconnect( btnAddItem->menu(), SIGNAL( triggered( QAction* ) ),
Expand Down Expand Up @@ -685,7 +691,7 @@ void QgsStyleV2ManagerDialog::removeItem()
bool QgsStyleV2ManagerDialog::removeSymbol() bool QgsStyleV2ManagerDialog::removeSymbol()
{ {
QModelIndexList indexes = listItems->selectionModel()->selectedIndexes(); QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
Q_FOREACH ( const QModelIndex& index, indexes ) Q_FOREACH( const QModelIndex& index, indexes )
{ {
QString symbolName = index.data().toString(); QString symbolName = index.data().toString();
// delete from style and update list // delete from style and update list
Expand Down Expand Up @@ -760,7 +766,7 @@ void QgsStyleV2ManagerDialog::exportSelectedItemsImages( QString dir, QString fo
return; return;


QModelIndexList indexes = listItems->selectionModel()->selection().indexes(); QModelIndexList indexes = listItems->selectionModel()->selection().indexes();
Q_FOREACH ( const QModelIndex& index, indexes ) Q_FOREACH( const QModelIndex& index, indexes )
{ {
QString name = index.data().toString(); QString name = index.data().toString();
QString path = dir + "/" + name + "." + format; QString path = dir + "/" + name + "." + format;
Expand Down Expand Up @@ -1151,11 +1157,11 @@ void QgsStyleV2ManagerDialog::regrouped( QStandardItem *item )
void QgsStyleV2ManagerDialog::setSymbolsChecked( QStringList symbols ) void QgsStyleV2ManagerDialog::setSymbolsChecked( QStringList symbols )
{ {
QStandardItemModel *model = qobject_cast<QStandardItemModel*>( listItems->model() ); QStandardItemModel *model = qobject_cast<QStandardItemModel*>( listItems->model() );
Q_FOREACH ( const QString& symbol, symbols ) Q_FOREACH( const QString& symbol, symbols )
{ {
QList<QStandardItem*> items = model->findItems( symbol ); QList<QStandardItem*> items = model->findItems( symbol );
Q_FOREACH ( QStandardItem* item, items ) Q_FOREACH( QStandardItem* item, items )
item->setCheckState( Qt::Checked ); item->setCheckState( Qt::Checked );
} }
} }


Expand Down Expand Up @@ -1198,27 +1204,27 @@ void QgsStyleV2ManagerDialog::tagsChanged()
return; return;
} }
// compare old with new to find removed tags // compare old with new to find removed tags
Q_FOREACH ( const QString &tag, oldtags ) Q_FOREACH( const QString &tag, oldtags )
{ {
if ( !newtags.contains( tag ) ) if ( !newtags.contains( tag ) )
removetags.append( tag ); removetags.append( tag );
} }
if ( removetags.size() > 0 ) if ( removetags.size() > 0 )
{ {
Q_FOREACH ( const QModelIndex& index, indexes ) Q_FOREACH( const QModelIndex& index, indexes )
{ {
mStyle->detagSymbol( type, index.data().toString(), removetags ); mStyle->detagSymbol( type, index.data().toString(), removetags );
} }
} }
// compare new with old to find added tags // compare new with old to find added tags
Q_FOREACH ( const QString &tag, newtags ) Q_FOREACH( const QString &tag, newtags )
{ {
if ( !oldtags.contains( tag ) ) if ( !oldtags.contains( tag ) )
addtags.append( tag ); addtags.append( tag );
} }
if ( addtags.size() > 0 ) if ( addtags.size() > 0 )
{ {
Q_FOREACH ( const QModelIndex& index, indexes ) Q_FOREACH( const QModelIndex& index, indexes )
{ {
mStyle->tagSymbol( type, index.data().toString(), addtags ); mStyle->tagSymbol( type, index.data().toString(), addtags );
} }
Expand Down Expand Up @@ -1339,7 +1345,7 @@ void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
groupList->setTitle( tr( "Apply Group" ) ); groupList->setTitle( tr( "Apply Group" ) );


QStringList groups = mStyle->groupNames(); QStringList groups = mStyle->groupNames();
Q_FOREACH ( const QString& group, groups ) Q_FOREACH( const QString& group, groups )
{ {
groupList->addAction( group ); groupList->addAction( group );
} }
Expand All @@ -1362,7 +1368,7 @@ void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
groupId = mStyle->groupId( selectedItem->text() ); groupId = mStyle->groupId( selectedItem->text() );
} }
QModelIndexList indexes = listItems->selectionModel()->selectedIndexes(); QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
Q_FOREACH ( const QModelIndex& index, indexes ) Q_FOREACH( const QModelIndex& index, indexes )
{ {
mStyle->group( type, index.data().toString(), groupId ); mStyle->group( type, index.data().toString(), groupId );
} }
Expand Down

0 comments on commit 29fc46a

Please sign in to comment.