Skip to content

Commit 7368e7f

Browse files
committedJul 31, 2020
fix applying styles from QML files with missing colorramp node
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.
1 parent 1ed8e41 commit 7368e7f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/gui/raster/qgscolorrampshaderwidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,6 @@ void QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited( QTreeWidgetItem *
644644

645645
void QgsColorRampShaderWidget::setFromShader( const QgsColorRampShader &colorRampShader )
646646
{
647-
populateColormapTreeWidget( colorRampShader.colorRampItemList() );
648-
649647
// Those objects are connected to classify() the color ramp shader if they change, or call widget change
650648
// need to block them to avoid to classify and to alter the color ramp, or to call duplicate widget change
651649
whileBlocking( mClipCheckBox )->setChecked( colorRampShader.clip() );
@@ -666,6 +664,8 @@ void QgsColorRampShaderWidget::setFromShader( const QgsColorRampShader &colorRam
666664
btnColorRamp->setColorRampFromName( defaultPalette );
667665
}
668666

667+
populateColormapTreeWidget( colorRampShader.colorRampItemList() );
668+
669669
emit widgetChanged();
670670
}
671671

0 commit comments

Comments
 (0)
Please sign in to comment.