Skip to content

Commit

Permalink
fix applying styles from QML files with missing colorramp node
Browse files Browse the repository at this point in the history
When applying a style file with a colorrampshader node but without
a colorramp node, the actual color values of the items of the ramp
are overwritten by the default ramp (currently 'Spectral'). Files
with not colorramp node happened to be created by earlier QGIS
versions - at least with 2.10.

This is because the default ramp is applied after populating the
color ramp item list. Applying a color ramp emits a
colorRampChanged() signal. This signal causes new colors from the
ramp applied to the items, overwriting the already set ones.

This is not desired. Fix by populating the item list after applying
the color ramp.
  • Loading branch information
iona5 committed Jul 31, 2020
1 parent 1ed8e41 commit 7368e7f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gui/raster/qgscolorrampshaderwidget.cpp
Expand Up @@ -644,8 +644,6 @@ void QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited( QTreeWidgetItem *

void QgsColorRampShaderWidget::setFromShader( const QgsColorRampShader &colorRampShader )
{
populateColormapTreeWidget( colorRampShader.colorRampItemList() );

// Those objects are connected to classify() the color ramp shader if they change, or call widget change
// need to block them to avoid to classify and to alter the color ramp, or to call duplicate widget change
whileBlocking( mClipCheckBox )->setChecked( colorRampShader.clip() );
Expand All @@ -666,6 +664,8 @@ void QgsColorRampShaderWidget::setFromShader( const QgsColorRampShader &colorRam
btnColorRamp->setColorRampFromName( defaultPalette );
}

populateColormapTreeWidget( colorRampShader.colorRampItemList() );

emit widgetChanged();
}

Expand Down

0 comments on commit 7368e7f

Please sign in to comment.