Skip to content

Commit

Permalink
[processing] reload output layer after GDAL rasterize (fix #45729)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy authored and nyalldawson committed Feb 1, 2022
1 parent c222af7 commit 2b77734
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
22 changes: 22 additions & 0 deletions python/plugins/processing/algs/gdal/rasterize_over.py
Expand Up @@ -125,3 +125,25 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(inLayer.source())

return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

def postProcessAlgorithm(self, context, feedback):
fileName = self.output_values.get(self.OUTPUT)
if not fileName:
return {}

if context.project():
for l in context.project().mapLayers().values():
if l.source() != fileName:
continue

l.dataProvider().reloadData()
l.triggerRepaint()

for l in context.temporaryLayerStore().mapLayers().values():
if l.source() != fileName:
continue

l.dataProvider().reloadData()
context.temporaryLayerStore().addMapLayer(l)

return {}
23 changes: 23 additions & 0 deletions python/plugins/processing/algs/gdal/rasterize_over_fixed_value.py
Expand Up @@ -26,6 +26,7 @@
from qgis.PyQt.QtGui import QIcon

from qgis.core import (QgsRasterFileWriter,
QgsProcessingContext,
QgsProcessingException,
QgsProcessingParameterDefinition,
QgsProcessingParameterFeatureSource,
Expand Down Expand Up @@ -122,3 +123,25 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(inLayer.source())

return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

def postProcessAlgorithm(self, context, feedback):
fileName = self.output_values.get(self.OUTPUT)
if not fileName:
return {}

if context.project():
for l in context.project().mapLayers().values():
if l.source() != fileName:
continue

l.dataProvider().reloadData()
l.triggerRepaint()

for l in context.temporaryLayerStore().mapLayers().values():
if l.source() != fileName:
continue

l.dataProvider().reloadData()
context.temporaryLayerStore().addMapLayer(l)

return {}

0 comments on commit 2b77734

Please sign in to comment.