Skip to content
Permalink
Browse files

[processing] Fix exception when clicking alg with distance param in h…

…istory dialog
  • Loading branch information
nyalldawson committed Jul 2, 2018
1 parent cb144b3 commit 16214026527e5349a344ef67c490e63e5c3a8505
Showing with 12 additions and 2 deletions.
  1. +12 −2 python/plugins/processing/gui/NumberInputPanel.py
@@ -143,6 +143,8 @@ def __init__(self, param):
super(NumberInputPanel, self).__init__(None)
self.setupUi(self)

self.layer = None

self.spnValue.setExpressionsEnabled(True)

self.param = param
@@ -211,7 +213,8 @@ def __init__(self, param):

def setDynamicLayer(self, layer):
try:
self.btnDataDefined.setVectorLayer(self.getLayerFromValue(layer))
self.layer = self.getLayerFromValue(layer)
self.btnDataDefined.setVectorLayer(self.layer)
except:
pass

@@ -221,7 +224,14 @@ def getLayerFromValue(self, value):
value, ok = value.source.valueAsString(context.expressionContext())
if isinstance(value, str):
value = QgsProcessingUtils.mapLayerFromString(value, context)
return value
if value is None:
return None

# need to return layer with ownership - otherwise layer may be deleted when context
# goes out of scope
new_layer = context.takeResultLayer(value.id())
# if we got ownership, return that - otherwise just return the layer (which may be owned by the project)
return new_layer if new_layer is not None else value

def getValue(self):
if self.btnDataDefined is not None and self.btnDataDefined.isActive():

0 comments on commit 1621402

Please sign in to comment.
You can’t perform that action at this time.