Created attachment 117158 [details] Freezed window after reproducing bug SUMMARY STEPS TO REPRODUCE 1. OPEN Scripter FROM "Tools" tab (Tools->Scripts->Scripter) 2. ENTER "quit()" in line 1 3. RUN script OBSERVED RESULT Main window disappears, while "Scripter - Krita" window freezes until user closes it manually (though other times it just crashes). EXPECTED RESULT An Error in scripting shell SOFTWARE/OS VERSIONS Windows: 10 Qt Version: 5.9.3 ADDITIONAL INFORMATION Krita Version: 4.1.7 Qt Version (compiled): 5.9.3 Version (loaded): 5.9.3 OS Information Build ABI: x86_64-little_endian-llp64 Build CPU: x86_64 CPU: x86_64 Kernel Type: winnt Kernel Version: 10.0.17134 Pretty Productname: Windows 10 (10.0) Product Type: windows Product Version: 10 OpenGL Info **OpenGL not initialized**
Oh gosh, I'm not sure that's actually doable...
(In reply to Boudewijn Rempt from comment #1) > Oh gosh, I'm not sure that's actually doable... From what I know quit() exits python( and goes back in command prompt if you launched python interpreter from cmd) so it should be unallowed command
Yeah... But I don't know how we could remove that from the interpreter. Maybe it's just one the things people shouldn't do.
All that the quit and exit functions do is raise a SystemExit Exception that can be caught. Here's an example of how to do that on the embedding level: http://www.myoddweb.com/2016/03/02/preventing-embedded-python-from-killing-your-app/ This would prevent any plugin to kill Krita with raising a SystemExit. Additionally, it would probably be a good idea to have the Scripter Plugin catch the exception itself on the Python level and simply close itself gracefully. I haven't got around to compiling Krita myself yet, otherwise I'd play around with it myself.
I've submitted a patch that fixes the problem from the Scripter side: https://phabricator.kde.org/D17962 This still doesn't solve the problem of other Python Plugins raising a SystemExit and crashing Krita. I had both Segfaults and Sigabort with my version compiled in docker, but I don't understand the C++ side of things enough to know what's going on.
Git commit e5ee9c48a3fd09da4bf73863228cc90a77726529 by Boudewijn Rempt. Committed on 16/01/2019 at 09:42. Pushed by rempt into branch 'master'. Catch SystemExit Exception in Scripter Differential Revision:https://phabricator.kde.org/D17962 Patch by Rebecca Breu, thanks! M +3 -0 plugins/python/scripter/ui_scripter/actions/runaction/runaction.py https://commits.kde.org/krita/e5ee9c48a3fd09da4bf73863228cc90a77726529