Skip to content

Commit

Permalink
error message when setData called for non existent row
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-languagetools committed Feb 8, 2022
1 parent 1d5ea30 commit 3bc87ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions component_text_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def setData(self, index, value, role):
column = index.column()
row = index.row()

if row >= len(self.model.get_text_replacement_rules()):
logging.error(f'setData column {column} row {row}, num rules: {len(self.model.get_text_replacement_rules())}')
return False

text_replacement_rule = self.model.get_text_replacement_rule_row(row)

if role == PyQt5.QtCore.Qt.EditRole:
Expand Down
14 changes: 14 additions & 0 deletions test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,20 @@ def test_text_processing(qtbot):

# dialog.exec_()

def test_text_processing_manual(qtbot):
config_gen = testing_utils.TestConfigGenerator()
hypertts_instance = config_gen.build_hypertts_instance_test_servicemanager('default')

dialog = EmptyDialog()
dialog.setupUi()

model_change_callback = MockModelChangeCallback()
text_processing = component_text_processing.TextProcessing(hypertts_instance, model_change_callback.model_updated)
dialog.addChildLayout(text_processing.draw())

if os.environ.get('HYPERTTS_TEXT_PROCESSING_DIALOG_DEBUG', 'no') == 'yes':
dialog.exec_()

def test_configuration(qtbot):
config_gen = testing_utils.TestConfigGenerator()
hypertts_instance = config_gen.build_hypertts_instance_test_servicemanager('default')
Expand Down

0 comments on commit 3bc87ec

Please sign in to comment.