mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Fix wrapped c++ object has been deleted error when editing model parameters
Fixes #16858
This commit is contained in:
parent
ebda2fd212
commit
370b26798f
@ -195,8 +195,7 @@ class ModelerGraphicItem(QGraphicsItem):
|
||||
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 @@ class ModelerParameterDefinitionDialog(QDialog):
|
||||
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 @@ class ModelerParameterDefinitionDialog(QDialog):
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user