code-saturne / code_saturne

code_saturne public mirror
https://www.code-saturne.org
GNU General Public License v2.0
225 stars 82 forks source link

Problem in the GUI when we put an existing name for a user scalar #73

Closed YohannEude closed 3 years ago

YohannEude commented 3 years ago

Hi,

If you add in the "Species transport" panel a "scalar1" then a "scalar2" and you try to change the name of scalar 2 to scalar1, there is the following error: Traceback (most recent call last): File "--------code_saturne/Pages/DefineUserScalarsView.py", line 120, in setModelData dialog = VerifyExistenceLabelDialogView(self.parent, default) File "--------code_saturne/Pages/VerifyExistenceLabelDialogView.py", line 59, in init self.default['list'].remove(self.default['label']) KeyError: 'label'

To solve that, we just changed in DefineUserScalarsView.py the two functions setModelData in NameDelegate and VarianceNameDelegate with:

default = {} default['label'] = self.old_pname default['name'] = self.old_pname default['list'] = model.mdl.getScalarNameList() default['regexp'] = self.regExp

With these new modifications, a pop-up window appears as a warning for the user and the user can then change the name.

Regards,

Yohann

YohannEude commented 3 years ago

In addition, in order to avoid to the user to put a name equal to the one of the thermal one, we change in the two functions setModelData in NameDelegate and VarianceNameDelegate the lines : if new_pname in model.mdl.getScalarNameList() by if new_pname in model.mdl.getScalarNameList() + model.mdl.getThermalScalarName():

Regards,

Yohann

YvanFournier commented 3 years ago

Fix included in commit 05990a47.