Bug 387884

Summary: Scripter does not run edits unless saved
Product: [Applications] krita Reporter: Brendan <bunf2014>
Component: ScriptingAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: griffinvalley
Priority: NOR    
Version First Reported In: 4.0 pre-alpha   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Brendan 2017-12-14 02:15:02 UTC
If a scripter script has been saved, using the Run action causes scripter to load and run the script from its associated file - even if there are unsaved changes in the script window. 

To reproduce:
start scripter
file->new script 
print("hello")
file-> save (choose filename and save)
press Run/Ctrl-R:

======================================
hello

add to edit window:
print("world")
press Run/Ctrl-R:

======================================
hello


That is, "world" is not printed, despite being in the edit window. This is because saving the document sets _activeDocument flag and that causes the script to load directly from the file. 

There are different approaches to solving this
* add a dirty flag to the edit box and check that, put a dialog up to query saving before running - or visual indicator that script has been changed or 
toolbar warning that running script from file
* automatically save edit window before running (or have this as an option in settings)
* have separate actions save+run (... from the file) and run (...from the editor window)
* have separate actions run from file, run from editor (manual saving)
* have a "run-from-file" mode which doesn't display the edit window - or makes it read only?
* run only script in window
* some combination

I personally would like to be able to run scripts directly from the file - so that I can use a different editor.

Wanted feedback on UI before diving into patching.
Comment 1 wolthera 2017-12-14 13:35:08 UTC
This is already fixed in master. It will track if the document is modified, inform the user of that during run and in the status bar, and if it is modified, only run the script in the terminal.
Comment 2 Brendan 2017-12-23 04:50:35 UTC
This bug is present in commit 61a84e2 (15 Dec)
When you save a script it seems to uncouple the connection to setDocumentModified - undo is available (press ctrl-Z!) but the signal is not setting off setDocumentModified.
Comment 3 Brendan 2017-12-23 08:28:52 UTC
also in 9dd5c1a