diff --git a/Orange/widgets/evaluate/owpredictions.py b/Orange/widgets/evaluate/owpredictions.py index 16248d6bbe7..243588d69ad 100644 --- a/Orange/widgets/evaluate/owpredictions.py +++ b/Orange/widgets/evaluate/owpredictions.py @@ -15,7 +15,6 @@ QModelIndex, QAbstractTableModel, QSortFilterProxyModel, pyqtSignal, QTimer, QItemSelectionModel, QItemSelection) -from Orange.widgets.utils.colorpalettes import LimitedDiscretePalette from orangewidget.report import plural import Orange @@ -32,6 +31,7 @@ from Orange.widgets.utils.itemmodels import TableModel from Orange.widgets.utils.sql import check_sql_input from Orange.widgets.utils.state_summary import format_summary_details +from Orange.widgets.utils.colorpalettes import LimitedDiscretePalette # Input slot for the Predictors channel @@ -1054,7 +1054,10 @@ def select(self, selection: Union[QModelIndex, QItemSelection], flags: int): flags that tell whether to Clear, Select, Deselect or Toggle """ if isinstance(selection, QModelIndex): - rows = {selection.model().mapToSource(selection).row()} + if selection.model() is not None: + rows = {selection.model().mapToSource(selection).row()} + else: + rows = set() else: indices = selection.indexes() if indices: @@ -1108,11 +1111,12 @@ def map_from_source(rows): try: yield finally: - deselected = map_from_source(old_rows - self._rows) - selected = map_from_source(self._rows - old_rows) - if selected or deselected: - for model in self._selection_models: - model.emit_selection_rows_changed(selected, deselected) + if self.proxy.sourceModel() is not None: + deselected = map_from_source(old_rows - self._rows) + selected = map_from_source(self._rows - old_rows) + if selected or deselected: + for model in self._selection_models: + model.emit_selection_rows_changed(selected, deselected) class SharedSelectionModel(QItemSelectionModel):