Skip to content

Commit

Permalink
when saving C model, run model check and highlight C window if error …
Browse files Browse the repository at this point in the history
…with C code. Clear highlights from both python and C windows if checks pass. Ensure that checkModel() is always passed a path argument instead of raw text.
  • Loading branch information
tsole0 committed Jun 26, 2024
1 parent 2b71022 commit eb3dee0
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/sas/qtgui/Utilities/TabbedModelEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def loadFile(self, filename):

# Check the validity of loaded model if the model is python
if self.is_python:
error_line = self.checkModel(plugin_text)
error_line = self.checkModel(self.filename)
if error_line > 0:
# select bad line
cursor = QtGui.QTextCursor(self.editor_widget.txtEditor.document().findBlockByLineNumber(error_line-1))
Expand Down Expand Up @@ -439,9 +439,20 @@ def updateFromEditor(self):
# Get model filepath
plugin_location = models.find_plugins_dir()
full_path = os.path.join(plugin_location, filename)
if os.path.splitext(full_path)[1] != ".py":
if not w.is_python and self.is_python:
pass
elif os.path.splitext(full_path)[1] != ".py":
full_path += ".py"

# Check model as long as there is a .py file in one of the tabs
if w.is_python and self.is_python:
check_model = True
elif not w.is_python and self.is_python:
# Set full_path to the .py file so that we can run a model check on it (the .py model should link to the .c model)
full_path = self.filename.with_suffix(".py")
check_model = True

if check_model:
error_line = self.checkModel(full_path)
if error_line > 0:
# select bad line
Expand All @@ -450,8 +461,13 @@ def updateFromEditor(self):
return

# change the frame colours back
w.txtEditor.setStyleSheet("")
w.txtEditor.setToolTip("")
try:
self.c_editor_widget.txtEditor.setStyleSheet("")
self.c_editor_widget.txtEditor.setToolTip("")
except AttributeError:
pass
self.editor_widget.txtEditor.setStyleSheet("")
self.editor_widget.txtEditor.setToolTip("")

# Update the tab title
self.setTabEdited(False)
Expand Down

0 comments on commit eb3dee0

Please sign in to comment.