Skip to content

Commit 40f3c8c

Browse files
committed
Fix setting layers to match canvas theme
1 parent 1e6bffe commit 40f3c8c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/gui/qgsmapcanvas.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,6 @@ void QgsMapCanvas::refreshMap()
488488
if ( !mTheme.isEmpty() )
489489
{
490490
mSettings.setLayerStyleOverrides( QgsProject::instance()->mapThemeCollection()->mapThemeStyleOverrides( mTheme ) );
491-
mSettings.setLayers( QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( mTheme ) );
492-
}
493-
else
494-
{
495-
mSettings.setLayerStyleOverrides( QMap< QString, QString>() );
496491
}
497492

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

1626-
mTheme = theme;
16271621
clearCache();
1628-
emit themeChanged( theme );
1622+
if ( theme.isEmpty() || !QgsProject::instance()->mapThemeCollection()->hasMapTheme( theme ) )
1623+
{
1624+
mTheme.clear();
1625+
mSettings.setLayerStyleOverrides( QMap< QString, QString>() );
1626+
emit themeChanged( QString() );
1627+
}
1628+
else
1629+
{
1630+
mTheme = theme;
1631+
setLayers( QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( mTheme ) );
1632+
emit themeChanged( theme );
1633+
}
16291634
}
16301635

16311636
void QgsMapCanvas::setRenderFlag( bool flag )

0 commit comments

Comments
 (0)