Skip to content

Commit

Permalink
Fix wrapped c++ object has been deleted error when editing model para…
Browse files Browse the repository at this point in the history
…meters

Fixes #16858
  • Loading branch information
nyalldawson committed Aug 18, 2017
1 parent ebda2fd commit 370b267
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
3 changes: 1 addition & 2 deletions python/plugins/processing/modeler/ModelerGraphicItem.py
Expand Up @@ -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())
Expand Down
Expand Up @@ -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'),
Expand Down Expand Up @@ -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.