Skip to content
Permalink
Browse files

Fix wrapped c++ object has been deleted error when editing model para…

…meters

Fixes #16858
  • Loading branch information
nyalldawson committed Aug 18, 2017
1 parent ebda2fd commit 370b26798f459e4aabea8a174346b13b3f90b8ea
@@ -195,8 +195,7 @@ def editElement(self):
if isinstance(self.element, QgsProcessingModelParameter):
dlg = ModelerParameterDefinitionDialog(self.model,
param=self.model.parameterDefinition(self.element.parameterName()))
dlg.exec_()
if dlg.param is not None:
if dlg.exec_() and dlg.param is not None:
self.model.removeModelParameter(self.element.parameterName())
self.element.setParameterName(dlg.param.name())
self.element.setDescription(dlg.param.name())
@@ -297,15 +297,15 @@ def setupUi(self):
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel |
QDialogButtonBox.Ok)
self.buttonBox.setObjectName('buttonBox')
self.buttonBox.accepted.connect(self.okPressed)
self.buttonBox.rejected.connect(self.cancelPressed)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)

self.verticalLayout.addStretch()
self.verticalLayout.addWidget(self.buttonBox)

self.setLayout(self.verticalLayout)

def okPressed(self):
def accept(self):
description = str(self.nameTextBox.text())
if description.strip() == '':
QMessageBox.warning(self, self.tr('Unable to define parameter'),
@@ -401,8 +401,16 @@ def okPressed(self):
self.param = QgsProcessingParameterCrs(name, description, self.selector.crs().authid())
if not self.requiredCheck.isChecked():
self.param.setFlags(self.param.flags() | QgsProcessingParameterDefinition.FlagOptional)
self.close()

def cancelPressed(self):
settings = QgsSettings()
settings.setValue("/Processing/modelParametersDefinitionDialogGeometry", self.saveGeometry())

QDialog.accept(self)

def reject(self):
self.param = None
self.close()

settings = QgsSettings()
settings.setValue("/Processing/modelParametersDefinitionDialogGeometry", self.saveGeometry())

QDialog.reject(self)

0 comments on commit 370b267

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