Skip to content

Commit

Permalink
Fix setting layers to match canvas theme
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 12, 2017
1 parent 1e6bffe commit 40f3c8c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -488,11 +488,6 @@ void QgsMapCanvas::refreshMap()
if ( !mTheme.isEmpty() )
{
mSettings.setLayerStyleOverrides( QgsProject::instance()->mapThemeCollection()->mapThemeStyleOverrides( mTheme ) );
mSettings.setLayers( QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( mTheme ) );
}
else
{
mSettings.setLayerStyleOverrides( QMap< QString, QString>() );
}

// create the renderer job
Expand Down Expand Up @@ -1623,9 +1618,19 @@ void QgsMapCanvas::setTheme( const QString &theme )
if ( mTheme == theme )
return;

mTheme = theme;
clearCache();
emit themeChanged( theme );
if ( theme.isEmpty() || !QgsProject::instance()->mapThemeCollection()->hasMapTheme( theme ) )
{
mTheme.clear();
mSettings.setLayerStyleOverrides( QMap< QString, QString>() );
emit themeChanged( QString() );
}
else
{
mTheme = theme;
setLayers( QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( mTheme ) );
emit themeChanged( theme );
}
}

void QgsMapCanvas::setRenderFlag( bool flag )
Expand Down

0 comments on commit 40f3c8c

Please sign in to comment.