mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
plug-ins: python-fu-eval should correctly exit with error.
When the passed code had a bug, the plug-in was crashing along with the code given in argument. Instead, we must catch all exceptions and pass the error message raised by exec() to the core application.
This commit is contained in:
parent
8cf1aaf40f
commit
97fb23e5b3
1 changed files with 13 additions and 3 deletions
|
@ -28,13 +28,23 @@ from gi.repository import GLib
|
|||
from gi.repository import Gio
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
|
||||
def code_eval(procedure, run_mode, code, config, data):
|
||||
retval = Gimp.PDBStatusType.SUCCESS
|
||||
gerror = GLib.Error()
|
||||
|
||||
if code == '-':
|
||||
code = sys.stdin.read()
|
||||
|
||||
try:
|
||||
exec(code, globals())
|
||||
return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, GLib.Error())
|
||||
except Exception as error:
|
||||
retval = Gimp.PDBStatusType.CALLING_ERROR
|
||||
gerror = GLib.Error(traceback.format_exc())
|
||||
|
||||
return procedure.new_return_values(retval, gerror)
|
||||
|
||||
class PythonEval (Gimp.PlugIn):
|
||||
## GimpPlugIn virtual methods ##
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue