Skip to content

Commit 0d0a81b

Browse files
committed
Clearing map canvas theme falls back to project layers
1 parent 7f85169 commit 0d0a81b

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/gui/qgsmapcanvas.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,7 @@ void QgsMapCanvas::setTheme( const QString &theme )
16481648
{
16491649
mTheme.clear();
16501650
mSettings.setLayerStyleOverrides( QMap< QString, QString>() );
1651+
setLayers( QgsProject::instance()->mapThemeCollection()->masterVisibleLayers() );
16511652
emit themeChanged( QString() );
16521653
}
16531654
else

src/gui/qgsmapcanvas.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
323323
* QgsLayerTreeMapCanvasBridge.
324324
*
325325
* If an empty string is passed then the current theme association will be
326-
* cleared. The layers from the previously associated theme will remain
327-
* in the canvas, and a call to setLayers() may be necessary to define
328-
* which layers should be shown in the canvas.
326+
* cleared.
329327
* @note added in QGIS 3.0
330328
* @see theme()
331329
*/

tests/src/python/test_qgsmapcanvas.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,13 @@ def testMapTheme(self):
314314
canvas.waitWhileRendering()
315315
self.assertTrue(self.canvasImageCheck('theme4', 'theme4', canvas))
316316

317+
# clear theme
318+
canvas.setTheme('')
319+
canvas.refresh()
320+
canvas.waitWhileRendering()
321+
# should be different - we should now render project layers
322+
self.assertFalse(self.canvasImageCheck('theme4', 'theme4', canvas))
323+
317324
def canvasImageCheck(self, name, reference_image, canvas):
318325
self.report += "<h2>Render {}</h2>\n".format(name)
319326
temp_dir = QDir.tempPath() + '/'

0 commit comments

Comments
 (0)