Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Predictions: Fix crash when clicking on empty left area #5222

Merged
merged 1 commit into from
Feb 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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