Skip to content

Commit

Permalink
Merge pull request #5222 from janezd/fix-predictions-empty-click
Browse files Browse the repository at this point in the history
[FIX] Predictions: Fix crash when clicking on empty left area
  • Loading branch information
ajdapretnar authored Feb 5, 2021
2 parents ffa3df1 + 04c271e commit b6a16b1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Orange/widgets/evaluate/owpredictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b6a16b1

Please sign in to comment.