Skip to content

Commit

Permalink
Clearing map canvas theme falls back to project layers
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 13, 2017
1 parent 7f85169 commit 0d0a81b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1648,6 +1648,7 @@ void QgsMapCanvas::setTheme( const QString &theme )
{
mTheme.clear();
mSettings.setLayerStyleOverrides( QMap< QString, QString>() );
setLayers( QgsProject::instance()->mapThemeCollection()->masterVisibleLayers() );
emit themeChanged( QString() );
}
else
Expand Down
4 changes: 1 addition & 3 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -323,9 +323,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
* QgsLayerTreeMapCanvasBridge.
*
* If an empty string is passed then the current theme association will be
* cleared. The layers from the previously associated theme will remain
* in the canvas, and a call to setLayers() may be necessary to define
* which layers should be shown in the canvas.
* cleared.
* @note added in QGIS 3.0
* @see theme()
*/
Expand Down
7 changes: 7 additions & 0 deletions tests/src/python/test_qgsmapcanvas.py
Expand Up @@ -314,6 +314,13 @@ def testMapTheme(self):
canvas.waitWhileRendering()
self.assertTrue(self.canvasImageCheck('theme4', 'theme4', canvas))

# clear theme
canvas.setTheme('')
canvas.refresh()
canvas.waitWhileRendering()
# should be different - we should now render project layers
self.assertFalse(self.canvasImageCheck('theme4', 'theme4', canvas))

def canvasImageCheck(self, name, reference_image, canvas):
self.report += "<h2>Render {}</h2>\n".format(name)
temp_dir = QDir.tempPath() + '/'
Expand Down

0 comments on commit 0d0a81b

Please sign in to comment.