diff --git a/build_tools/requirements.txt b/build_tools/requirements.txt index d652b7e499..a0c7ba392d 100644 --- a/build_tools/requirements.txt +++ b/build_tools/requirements.txt @@ -26,7 +26,6 @@ lxml pytools cffi dominate -html5lib importlib-resources bumps html2text diff --git a/src/sas/qtgui/Utilities/TabbedModelEditor.py b/src/sas/qtgui/Utilities/TabbedModelEditor.py index c7d22b461e..8cce2613b6 100644 --- a/src/sas/qtgui/Utilities/TabbedModelEditor.py +++ b/src/sas/qtgui/Utilities/TabbedModelEditor.py @@ -39,6 +39,7 @@ def __init__(self, parent=None, edit_only=False): self.edit_only = edit_only self.is_modified = False self.label = None + self.builtinmodels = self.allBuiltinModels() self.addWidgets() @@ -141,6 +142,15 @@ def onLoad(self): self.tabWidget.removeTab(1) self.loadFile(filename) + def allBuiltinModels(self): + """ + create a list of all builtin models + """ + from sas.sascalc.fit.models import ModelManager + model_list = ModelManager().cat_model_list() + model_names = [model.name for model in model_list] + return model_names + def loadFile(self, filename): """ Performs the load operation and updates the view @@ -444,6 +454,14 @@ def canWriteModel(self, model=None, full_path=""): QtWidgets.QMessageBox.critical(self, "Plugin Error", msg) # Don't accept but return return False + + if model['filename'].casefold() in (model.casefold() for model in self.builtinmodels): + # notify the viewer + msg = "Built-in model with specified name already exists.\n" + msg += "Please specify different filename." + QtWidgets.QMessageBox.critical(self, "Plugin Error", msg) + # Don't accept but return + return False # Update model editor if plugin definition changed func_str = model['text'] msg = None