Repository: biolab/orange3

Issue:
PaintData: Output doesn't reset when Reset to Input Data is pressed
**Describe the bug**
When some file is set as input of Paint Data and if we add more points to the plot and then click `Reset to Input Data`, the plot resets but the actual output doesn't, the widget outputs all file instances plus those added ones. 

Additionally, when `Clear` is pressed the plot is empty and output is None and if then we click `Reset to Input Data`, the plot shows input instances but output is still None. 

**To Reproduce**
1. Connect Iris file to the Paint Data widget
2. Add more points on the plot / Clear the plot
3. Click `Reset to Input Data`
4. Connect Paint Data to Data Table and see the number of output instances

**Orange version:**
3.25.dev

**Expected behavior**
The widget resets and outputs (only) the input data.


Discussion:

Resolving patch:
diff --git a/Orange/widgets/data/owpaintdata.py b/Orange/widgets/data/owpaintdata.py
--- a/Orange/widgets/data/owpaintdata.py
+++ b/Orange/widgets/data/owpaintdata.py
@@ -1059,6 +1059,8 @@ def reset_to_input(self):
         else:  # set_dimensions already calls _replot, no need to call it again
             self._replot()
 
+        self.commit()
+
     def add_new_class_label(self, undoable=True):
 
         newlabel = next(label for label in namegen('C', 1)


Test patch:
diff --git a/Orange/widgets/data/tests/test_owpaintdata.py b/Orange/widgets/data/tests/test_owpaintdata.py
--- a/Orange/widgets/data/tests/test_owpaintdata.py
+++ b/Orange/widgets/data/tests/test_owpaintdata.py
@@ -4,7 +4,8 @@
 import numpy as np
 import scipy.sparse as sp
 
-from AnyQt.QtCore import QRectF, QPointF
+from AnyQt.QtCore import QRectF, QPointF, QEvent, Qt
+from AnyQt.QtGui import QMouseEvent
 
 from Orange.data import Table, DiscreteVariable, ContinuousVariable, Domain
 from Orange.widgets.data import owpaintdata
@@ -79,3 +80,31 @@ def test_load_empty_data(self):
         GH-2399
         """
         self.create_widget(OWPaintData, stored_settings={"data": []})
+
+    def test_reset_to_input(self):
+        """Checks if the data resets to input when Reset to Input is pressed"""
+        data = Table("iris")
+        self.send_signal(self.widget.Inputs.data, data)
+        output = self.get_output(self.widget.Outputs.data)
+        self.assertEqual(len(output), len(data))
+        self.widget.set_current_tool(self.widget.TOOLS[1][2]) # PutInstanceTool
+        tool = self.widget.current_tool
+        event = QMouseEvent(QEvent.MouseButtonPress, QPointF(0.17, 0.17),
+                            Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
+        tool.mousePressEvent(event)
+        output = self.get_output(self.widget.Outputs.data)
+        self.assertNotEqual(len(output), len(data))
+        self.assertEqual(len(output), 151)
+        self.widget.reset_to_input()
+        output = self.get_output(self.widget.Outputs.data)
+        self.assertEqual(len(output), len(data))
+
+        self.send_signal(self.widget.Inputs.data, data)
+        output = self.get_output(self.widget.Outputs.data)
+        self.assertEqual(len(output), len(data))
+        self.widget.set_current_tool(self.widget.TOOLS[5][2])  # ClearTool
+        output = self.get_output(self.widget.Outputs.data)
+        self.assertIsNone(output)
+        self.widget.reset_to_input()
+        output = self.get_output(self.widget.Outputs.data)
+        self.assertEqual(len(output), len(data))