From fa539f4db5f76db430b7dacc8363fcf3269a5d60 Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 19 Dec 2019 20:26:54 +0100 Subject: [PATCH] Table: Keep pending selection if data is None --- Orange/widgets/data/owtable.py | 7 ++----- Orange/widgets/data/tests/test_owtable.py | 9 +++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Orange/widgets/data/owtable.py b/Orange/widgets/data/owtable.py index d42689aa666..05c78808a81 100644 --- a/Orange/widgets/data/owtable.py +++ b/Orange/widgets/data/owtable.py @@ -519,20 +519,17 @@ def update(_): if current is not None: # pylint: disable=protected-access self.set_info(current._input_slot.summary) - else: - self.__pending_selected_rows = None - self.__pending_selected_cols = None self.tabs.tabBar().setVisible(self.tabs.count() > 1) self.openContext(data) - if self.__pending_selected_rows is not None: + if data and self.__pending_selected_rows is not None: self.selected_rows = self.__pending_selected_rows self.__pending_selected_rows = None else: self.selected_rows = [] - if self.__pending_selected_cols is not None: + if data and self.__pending_selected_cols is not None: self.selected_cols = self.__pending_selected_cols self.__pending_selected_cols = None else: diff --git a/Orange/widgets/data/tests/test_owtable.py b/Orange/widgets/data/tests/test_owtable.py index 2feaf4a0eec..e4de2e9b6c7 100644 --- a/Orange/widgets/data/tests/test_owtable.py +++ b/Orange/widgets/data/tests/test_owtable.py @@ -66,6 +66,15 @@ def test_unconditional_commit_on_new_signal(self): self.send_signal(self.widget.Inputs.data, self.data) commit.assert_called() + def test_pending_selection(self): + widget = self.create_widget(OWDataTable, stored_settings=dict( + selected_rows=[5, 6, 7, 8, 9], + selected_cols=list(range(len(self.data.domain))))) + self.send_signal(widget.Inputs.data, None, 1) + self.send_signal(widget.Inputs.data, self.data, 1) + output = self.get_output(widget.Outputs.selected_data) + self.assertEqual(5, len(output)) + if __name__ == "__main__": unittest.main()