[FIX] Python script widget: prevent data loss #3529
Conversation
|
Currently, this PR is changing a setting on every textChanged. I tried with long texts and it did not seem problematic. Still, I think saving scriptText belongs to storeSpecificSettings, but it is not called without a context. Should I then rather add a context handler? |
Codecov Report
@@ Coverage Diff @@
## master #3529 +/- ##
==========================================
+ Coverage 83.67% 83.68% +0.01%
==========================================
Files 370 370
Lines 66174 66213 +39
==========================================
+ Hits 55369 55412 +43
+ Misses 10805 10801 -4 |
560ade4 to
c240790
Compare
|
I changed the widget so that it does not waste time for copying text on every input by subclassing a SettingsHandler. The subclassed SettingsHandler runs a widget's method before packing settings. Ideas for a nicer solution? |
|
ContextHandler calls You could consider "promoting" this behaviour to SettingsHandler thus making it available to all widgets, not just those that use contexts? All widgets have this method (https://github.com/biolab/orange3/blob/master/Orange/widgets/widget.py#L882) and it does nothing by default so it should not break anything. |
|
@astaric, true, but I would do it in some other PR. Also the call to retrieveSpecificSettings should be moved... |
|
Then I would at least use the same widget method (storeSpecificSettings) for the job. This way, if the functionality is ever moved to SettingsHandler, a search for storeSpecificSettings will find this widget and PrepareSavingSettingsHandler can be removed at that point. |
fef20aa to
ddf514d
Compare
Before, if no script from the library was chosen when the user clicked "+" his current script would be lost.
astaric
left a comment
There was a problem hiding this comment.
Tested 1. and 2., both work as described.
When multiple scripts in the library are unsaved only the changes of the "active" one are saved in the workflow. The rest are still lost. Asking to save to library or discard when switching active script might be a solution (probably not in this PR)
The "library" allows me to deselect the current item (CMD clicking the currently selected item), and edit the script. The changes are "remembered" in the last selected item, but the changed indicator is not shown. When workflow is saved and restored, the changes are reapplied to the active script and changed indicator is shown.
Issue
Users were losing their scripts:
Fixes #3531
Description of changes
Includes